diff options
author | Jakob Kaivo <jkk@ung.org> | 2018-10-14 14:52:12 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2018-10-14 14:52:12 -0400 |
commit | 0eae9a1904143419d29d35b20b84c428d36dee0b (patch) | |
tree | 8d224da6a66fda666c5f3cb054a5a1d1e4e38e4e | |
parent | 773f948a2b2b6cd54a50a9f3eed8b12f4746be6d (diff) |
fix option handling
-rwxr-xr-x | color-ls | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -23,21 +23,20 @@ # SOFTWARE. # TODO: handle recursive stuff -# TODO: change this back to -C when that is fixed -output=x +output=C trim=1 +options= -while getopts ACFHLRSacdfgiklmnopqrstux1 option -do - case $option in +while getopts ACFHLRSacdfgiklmnopqrstux1 option; do + case ${option} in l|o|n|g) output=${option};; C|m|x) output=${option};; 1) output=1;; F) trim=0;; - ?) ;; + ?) options=${options}${option};; esac done -# FIXME: the script returns 0 even if ls does not -# FIXME: always pass -1 when needed, but do it before operands -ls -F ${1+$@} | awk -vtrim=${trim} -voutput=${output} -f $(dirname $0)/color-ls.awk +shift $(($OPTIND - 1)) + +exec ls -${options}F1 -- ${1+$*} | awk -vtrim=${trim} -voutput=${output} -f $(dirname $0)/color-ls.awk |