From f472159d99a50062a1e24fb54512bc8a9277f295 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 6 Nov 2000 08:46:01 +0000 Subject: *** empty log message *** --- tests/rwx-to-mode | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 tests/rwx-to-mode (limited to 'tests/rwx-to-mode') 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" -- cgit v1.2.3-70-g09d2