2 # Convert an ls-style permission string, like drwxr----x and -rw-r-x-wx
3 # to the equivalent chmod --mode (-m) argument, (=,u=rwx,g=r,o=x and
8 *) echo "$0: wrong number of arguments" 1>&2
9 echo "Usage: $0 ls-style-mode-string" 1>&2
14 [ld-
][rwx-
][rwx-
][rwxsS-
][rwx-
][rwx-
][rwxsS-
][rwx-
][rwx-
][rwxtT-
]) ;;
15 *) echo "$0: invalid mode string: $rwx" 1>&2; exit 1;;
18 # Perform these conversions:
23 # The `T' and `t' ones are only valid for `other'.
24 s
='s/S/@/;s/s/x@/;s/@/s/'
25 t
='s/T/@/;s/t/x@/;s/@/t/'
27 u
=`echo $rwx|sed 's/^.\(...\).*/,u=\1/;s/-//g;s/^,u=$//;'$s`
28 g
=`echo $rwx|sed 's/^....\(...\).*/,g=\1/;s/-//g;s/^,g=$//;'$s`
29 o
=`echo $rwx|sed 's/^.......\(...\).*/,o=\1/;s/-//g;s/^,o=$//;'$s';'$t`