Ver código fonte

Work properly with '-' or /dev/stdin

/dev/stdin will be treated as normal file, albeit `test -s` would detect
it as non-existent.  '-' will cause STDIN to be used as wellm but will
omit header.
Alois Mahdal 10 anos atrás
pai
commit
89b02aacc0
1 arquivos alterados com 8 adições e 3 exclusões
  1. 8
    3
      src/include/pretty.sh

+ 8
- 3
src/include/pretty.sh Ver arquivo

@@ -335,9 +335,14 @@ _pretty__echo_files() {
335 335
     local fp
336 336
     for fp in "$@";
337 337
     do
338
-        test -s "$fp" || continue
339
-        echo "-- $fp --"
340
-        cat "$fp"
338
+        if test "$fp" = "-";
339
+        then
340
+            cat
341
+        elif test -s "$fp" || test "$fp" = "/dev/stdin";
342
+        then
343
+            echo "-- $fp --"
344
+            cat "$fp"
345
+        fi
341 346
     done
342 347
 }
343 348