User: Password:
|
|
Subscribe / Log in / New account

Fish - The friendly interactive shell

Fish - The friendly interactive shell

Posted May 26, 2005 15:51 UTC (Thu) by diehl (guest, #6413)
In reply to: Fish - The friendly interactive shell by mikachu
Parent article: Fish - The friendly interactive shell

Well, in my opinion I perfer to have ls have the behavior of of saying "no file
found" if a file does not exist, rather than giving an entire directory listing if the
file does not exist, which I find confusing. So I vote for implementing that
behavior, at least as an option.


(Log in to post comments)

Fish - The friendly interactive shell

Posted May 27, 2005 12:07 UTC (Fri) by liljencrantz (guest, #28458) [Link]

The reason fish does what it does right now is that I regularly do things like:

for i in *.c; [...]; end

Inside of shellscripts. I expect this to work even when *.c does not match anything. If *.c is not expanded in this case, this will result in stupid behaviour, unless I add an explicit check, which is clearly dumb.

Maybe the perfect compromise is to have *.c expand to nothing inside of scripts, but emit a syntax error in interactive mode?

Fish - The friendly interactive shell

Posted May 30, 2005 17:10 UTC (Mon) by Jyhem (guest, #29388) [Link]

Are you saying that if you write

for i in *.bak; rm $i; end

then if there is no backup file present, I will have all the files in the directory deleted ?

I hope you intend to implement "undo" :-D

Fish - The friendly interactive shell

Posted May 30, 2005 21:15 UTC (Mon) by liljencrantz (guest, #28458) [Link]

Look at your example again... If *.bak does not match anything, the for loop body will execute exactly zero times. So the rm command will _never_ be run. And even if it had, running rm without any parameters doas not remove anything. So you are doubly safe.

Fish - The friendly interactive shell

Posted Jun 1, 2005 19:29 UTC (Wed) by kjetilho (subscriber, #30261) [Link]

It would be bad to make the behaviour in scripts different from that in interactive use, often I just paste my recent command history and make it a script for later use. The obviously correct ;-) solution is to make globbing work differently in list context, ie. when used as an iterator in for loops.

Doing this correctly in bash is quite painful -- you need to handle case where the glob matches literally:

  for i in *.c; do
    [ "$i" = "*.c" -a ! -e "$i" ] && break
    do_stuff "$i"
  done

fish sure is neater:

  for i in *.c; do_stuff $i; end

Fish - The friendly interactive shell

Posted Jun 9, 2005 12:11 UTC (Thu) by liljencrantz (guest, #28458) [Link]

So many solutions to a single problem. What is really needed is a 'Do what i mean' command...


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds