2015-08-03 4:30 GMT+02:00 @lbutlr <krem...@kreme.com>: > > > On Aug 2, 2015, at 5:25 PM, Greg Reagle <greg.rea...@umbc.edu> wrote: > > > > On Sat, Aug 01, 2015 at 01:38:02PM -0600, @lbutlr wrote: > >> I was hoping the list was more active > > > > FYI, the GitHub site at https://github.com/fish-shell/fish-shell/issues > is very > > active with bug reports and feature requests. > > Yes, but I am looking more for “How-to” or “getting -started”. I haven’t > used it enough to request anything or even know if something might be a bug. > > > Anyway, is there any sort of writeup anyone’s done on something like > “fish > >> for bash users” or similar? > > > > The comparison at http://hyperpolyglot.org/unix-shells is good. Also, > have you > > read the FAQ at http://fishshell.com/docs/current/faq.html and the > tutorial at > > http://fishshell.com/docs/current/tutorial.html? > > I’ve read the tutorial, and skimmed the FAQ. > > >> fish seems to have some different ideas about how to do things > (preferring > >> functions in individual files over aliases or functions in a single > rcfile > >> for one) > > > > That's the default way, but you don't have to do it that way. You can > have all > > of your functions in one file if you like. You could put them all in > > config.fish. Fish supports the source command, so you can group them > into > > files however you like. > > Right. I meant to say that it might be better to try fish “the fish way” > as opposed to just trying to duplicate my bash setup. > > >> Also, I’m not sure what the advantage is to creating a whole lot of > files > >> each containing one to three lines in the functions folder. > > > > My guess is: The functions can be auto-loaded on first use that way, a > > performance gain over loading them all at start-up no matter whether > they get > > used. > > That makes sense. > > >> function gbz () { > >> for i in `ls | grep ".bz2"` ; do bzgrep -H "$*" $i; done > >> } > >> > >> If I am understanding the documentation, this would be rewritten into > …/functions/gbz.fish as > >> > >> function gbz > >> for i in *.bz2 > >> bzgrep -H $argv $i > >> end > >> end > > > > That looks right to me, but I haven't checked it. FYI, you can have the > for > > loop in fish in one line if you'd like--use semicolons. E.g. > > > > for i in (seq 5) ; echo $i; end > > > >> Yes? How to I pass all the args properly escaped or quoted? Just > “$argv” like > >> in the original? > > > > In fish, you just use $argv unquoted. This is exemplified in the > tutorial. > > That’s what i thought, but if I’m using bash and type > > % gbz text1 text2 > > I get results in the bz2 files for “text1 text2” while with fish I get: > > > gbz text1 text2 > > bzip2: Can't open input file text2: No such file or directory. > > and then it greps the files for text1. >
That is because it is expanded as: > bzgrep -H text1 text2 [found_file] (That is: search "text1" in files text2 and [found_file]) While you wanted is expanded as: > bzgrep -H "text1 text2" [found_file] I guess it is the reason why you have the double quotes surrounding $*. I am not fish expert, so I do not know if restoring the double quotes will solve your problem. Still I find it a not so good idea not to explicitely put your double quotes. Indeed, this removes the abilitiy to pass options as arguments to your command. And it makes your gbz command have a different behaviour than most common Unix commands. With the command someone provided, you would type: > gbz "text1 text2" -or equivalently- > gbz text1\ text2 which seems saner to me. > > > > >> What if I wanted to check that there was only one argv? Or similarly > what if > >> I wanted to parse argv[1] and argv[2] separately? > > > > Use count. Again, see the tutorial. Example > > for i in (seq (count $PATH)); echo $i : $PATH[$i]; end > > Ah. The tutorial just has count $PATH to count the number of elements in > the $Patch variable. > I guess you meant "$PATH" rather than "$Patch" > > the reliance on web to config some settings is a bit of an issue. A lot of > my work in the shell is to remote machines, so setting up Things via a web > interface simply doesn’t work. > > -- > You start a conversation you can't even finish it > You're talkin' a lot, but you're not sayin' anything > When I have nothing to say, my lips are sealed > Say something once, why say it again? > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Fish-users mailing list > Fish-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fish-users >
------------------------------------------------------------------------------
_______________________________________________ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users