From 0eae9a1904143419d29d35b20b84c428d36dee0b Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 14 Oct 2018 14:52:12 -0400 Subject: fix option handling --- color-ls | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/color-ls b/color-ls index ca23c87..d3b673a 100755 --- a/color-ls +++ b/color-ls @@ -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 -- cgit v1.2.1