summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/rwx-to-mode12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/rwx-to-mode b/tests/rwx-to-mode
new file mode 100755
index 000000000..52bb5d155
--- /dev/null
+++ b/tests/rwx-to-mode
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Convert an ls-style permission string, like drwxr----x and -rw-r-x-wx
+# to the equivalent chmod --mode (-m) argument, (=,u=rwx,g=r,o=x and
+# =,u=rw,g=rx,o=wx).
+
+# FIXME: handle special bits, too.
+
+rwx=$1
+u=`echo $rwx|sed 's/^.\(...\).*/\1/;s/-//g'`
+g=`echo $rwx|sed 's/^....\(...\).*/\1/;s/-//g'`
+o=`echo $rwx|sed 's/^.......\(...\).*/\1/;s/-//g'`
+echo "=,u=$u,g=$g,o=$o"