summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2018-10-14 14:52:12 -0400
committerJakob Kaivo <jkk@ung.org>2018-10-14 14:52:12 -0400
commit0eae9a1904143419d29d35b20b84c428d36dee0b (patch)
tree8d224da6a66fda666c5f3cb054a5a1d1e4e38e4e
parent773f948a2b2b6cd54a50a9f3eed8b12f4746be6d (diff)
fix option handling
-rwxr-xr-xcolor-ls17
1 files 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