echo x > a > b > c > d

2017-04-16 Thread 積丹尼 Dan Jacobson
Maybe bash should catch this
$ echo x > a > b > c > d
and print a warning.
Same with
$ cat < a < b < c < d



Re: echo x > a > b > c > d

2017-04-16 Thread Eduardo Bustamante
On Sun, Apr 16, 2017 at 6:42 PM, 積丹尼 Dan Jacobson  wrote:
> Maybe bash should catch this
> $ echo x > a > b > c > d
> and print a warning.
> Same with
> $ cat < a < b < c < d

Why? These are perfectly valid grammatical constructs. What kind of
warning are you expecting to see and why?



Re: echo x > a > b > c > d

2017-04-16 Thread 積丹尼 Dan Jacobson
OK sorry. I guess they make a lot of sense.



Re: echo x > a > b > c > d

2017-04-16 Thread Eduardo Bustamante
On Sun, Apr 16, 2017 at 7:40 PM, 積丹尼 Dan Jacobson  wrote:
> OK sorry. I guess they make a lot of sense.

These constructs are valid grammatically, and have a well defined
semantic meaning. See:

dualbus@debian:~$ strace -e open bash -c ': &1|tail -n5
open("a", O_RDONLY) = 3
open("b", O_RDONLY) = 3
open("c", O_RDONLY) = 3
open("d", O_RDONLY) = 3
+++ exited with 0 +++

dualbus@debian:~$ strace -e open bash -c ': >a >b >c >d' 2>&1|tail -n5
open("a", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
open("b", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
open("c", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
open("d", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
+++ exited with 0 +++

Yes, it might be an awkward thing to write in a script, but it's still
valid. If you want recommendations on bad shell scripting practices,
perhaps you might want to try shellcheck instead?



Re: echo x > a > b > c > d

2017-04-16 Thread 積丹尼 Dan Jacobson
OK. (But shellcheck doesn't catch it either.)
$ { echo '#!/bin/sh'; echo 'echo x > c > c > c';}|shellcheck /dev/stdin
$ { echo '#!/bin/sh'; echo 'echo x < c < c < c';}|shellcheck /dev/stdin