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
4 # =,u=rw,g=rx,o=wx). Ignore ACLs.
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 [ld-
][rwx-
][rwx-
][rwxsS-
][rwx-
][rwx-
][rwxsS-
][rwx-
][rwx-
][rwxtT-
]+) ;;
16 *) echo "$0: invalid mode string: $rwx" 1>&2; exit 1;;
19 # Perform these conversions:
24 # The `T' and `t' ones are only valid for `other'.
25 s
='s/S/@/;s/s/x@/;s/@/s/'
26 t
='s/T/@/;s/t/x@/;s/@/t/'
28 u
=`echo $rwx|sed 's/^.\(...\).*/,u=\1/;s/-//g;s/^,u=$//;'$s`
29 g
=`echo $rwx|sed 's/^....\(...\).*/,g=\1/;s/-//g;s/^,g=$//;'$s`
30 o
=`echo $rwx|sed 's/^.......\(...\).*/,o=\1/;s/-//g;s/^,o=$//;'$s';'$t`