On Thu, Nov 25, 2010 at 5:45 AM, Grissiom <[email protected]> wrote: > Good patch. Much better than me. ;) > > But I have a few questions, not for your patch, but for the syntax > checker(or tokenizer if it does the job). > > On Thu, Nov 25, 2010 at 11:04 AM, Dylan Smith <[email protected]> > wrote: >> I tested fish_indent with the following test cases: >> >> for x in (seq 0 3) >> echo "cmd arg $x> outfile" | fish_indent >> echo "cmd arg $x^ outfile" | fish_indent >> echo "cmd arg $x< infile" | fish_indent >> echo "cmd arg $x>> appendfile" | fish_indent >> echo "cmd arg $x^^ appendfile" | fish_indent >> echo "cmd arg $x>| cmd" | fish_indent >> echo "cmd arg $x>&4" | fish_indent >> end >> --- >> # Output >> cmd arg 0> outfile >> cmd arg 0> outfile > > Actuarially, 1^ is invalid: > > ~/test> cat 1^ > fish: Expected redirection specification, got token of type “End of command” > cat 1^ > ^ > > so as 1^^.
Those are error redirections, so you need to append a filename, which in my command is outfile. > >> cmd arg < infile >> cmd arg 0>> appendfile >> cmd arg 0>> appendfile >> fish_indent: Unknown token 'Can not use fd 0 as pipe output' >> cmd arg 0>&4 > > Is it valid to redirect stdin to other files? Say, if I redirect stdin > to stdout in cat, it should yield what I input 3 times. But both fish > and bash give 2 times result: > > ~> cat 0>&1 > 1 > 1 > 2 > 2 > 3 > 3 > > I think redirect to a file is just like redirect to a pipe. (All the > things are files, right? ;) # Warning, using bash syntax for the next command dylan:~$ ls /proc/$$/fd -l total 0 lr-x------ 1 dylan users 64 Nov 25 08:08 0 -> /dev/pts/1 lrwx------ 1 dylan users 64 Nov 25 08:08 1 -> /dev/pts/1 lrwx------ 1 dylan users 64 Nov 25 08:08 2 -> /dev/pts/1 lrwx------ 1 dylan users 64 Nov 25 08:08 255 -> /dev/pts/1 Notice that fd 0, 1, 2 all point to the same device, a pseudo-terminal. Therefore copying one file descriptor to another doesn't do anything unless until one of them is pointed to something else first. The only difference is that fd 0 is read from and fd 1 is written to. > >> cmd arg > outfile >> cmd arg > outfile >> cmd arg 1< infile >> cmd arg >> appendfile >> cmd arg >> appendfile >> cmd arg | cmd >> cmd arg 1>&4 >> cmd arg ^ outfile >> cmd arg ^ outfile >> cmd arg 2< infile >> cmd arg ^^ appendfile >> cmd arg ^^ appendfile >> cmd arg ^| cmd >> cmd arg 2>&4 >> cmd arg 3> outfile >> cmd arg 3> outfile > > 3^ is invalid too. See 1^. > >> cmd arg 3< infile >> cmd arg 3>> appendfile >> cmd arg 3>> appendfile >> cmd arg 3>| cmd >> cmd arg 3>&4 >> > > -- > Cheers, > Grissiom > ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
