diff options
| -rwxr-xr-x | color-ls | 11 | ||||
| -rwxr-xr-x | color-ls.awk | 8 |
2 files changed, 11 insertions, 8 deletions
@@ -25,24 +25,19 @@ # TODO: handle recursive stuff # TODO: change this back to -C when that is fixed output=x -long=0 trim=1 while getopts ACFHLRSacdfgiklmnopqrstux1 option do case $option in - l|o|n|g) output=${option}; long=1;; - C|m|x) output=${option}; long=0;; + l|o|n|g) output=${option};; + C|m|x) output=${option};; 1) output=1;; F) trim=0;; ?) ;; esac done -if [ ${long} == 0 ]; then - dash_F=-F -fi - # FIXME: the script returns 0 even if ls does not # FIXME: always pass -1 when needed, but do it before operands -ls $dash_F ${1+$@} | awk -vwidest=0 -vlong=${long} -vtrim=${trim} -voutput=${output} -f $(dirname $0)/color-ls.awk +ls -F ${1+$@} | awk -vtrim=${trim} -voutput=${output} -f $(dirname $0)/color-ls.awk diff --git a/color-ls.awk b/color-ls.awk index fc5855c..e19c77a 100755 --- a/color-ls.awk +++ b/color-ls.awk @@ -22,6 +22,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +BEGIN { + long = 0; + widest = 0; + if (output == "l" || output == "o" || output == "n" || output == "g") { + long = 1; + } +} + function columns_down() { widest++; column = 0; |
