summaryrefslogtreecommitdiff
path: root/tests/rwx-to-mode
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-11-06 08:46:01 +0000
committerJim Meyering <jim@meyering.net>2000-11-06 08:46:01 +0000
commitf472159d99a50062a1e24fb54512bc8a9277f295 (patch)
treed83ffaeddfa2ebaba4dd1a136be30bb5b46339a5 /tests/rwx-to-mode
parent0e1b0b2ea20e601f24cd51bb4e9199ca1ae01a7c (diff)
downloadcoreutils-f472159d99a50062a1e24fb54512bc8a9277f295.tar.xz
*** empty log message ***
Diffstat (limited to 'tests/rwx-to-mode')
-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"