User: Password:
Subscribe / Log in / New account



Posted May 19, 2005 10:56 UTC (Thu) by modernjazz (guest, #4185)
Parent article: Fish - The friendly interactive shell

Presumably, rather than re-writing, the incompatibility issues can be
addressed by the #! /bin/bash syntax, using bash to run bash scripts, and
#! /bin/fish to run fish scripts? That way, one needs to re-write only
if one wants to take advantage of fish---older scripts will still work.

This looks like very promising work, thanks for taking the plunge!

(Log in to post comments)


Posted May 19, 2005 11:44 UTC (Thu) by liljencrantz (guest, #28458) [Link]

Right. But initialization scripts will have to be converted, and they can't be shared between shells. The latter is probably something that will make it much harder to get fish into any distributions.


Posted May 19, 2005 14:59 UTC (Thu) by modernjazz (guest, #4185) [Link]

I'm _not_ an expert, far from it. But how much of the end result of
initialization comes down to 2 things: setting environment variables and
aliases? If that's most of it, would it be possible to have fish: launch
a (say, bash) sub-shell for initialization, do the initialization in that
sub-shell, and then have fish simply parse the output of "env" and
"alias" commands running in that sub-shell?


Posted May 19, 2005 15:35 UTC (Thu) by liljencrantz (guest, #28458) [Link]

Good question. This is more or less what Red Hat already does on some files for tcsh, at least under Fedora Core 3. They have a bunch of shell scripts only containing lines like:


that are directly sourced by the init file under Bourne shells, and for tcsh, they run this monster:

eval `grep -v '^[:blank:]*#' $file | sed 's|\([^=]*\)=\([^=]*\)|setenv \1 \2|g' | sed 's|$|;|'`

Doing the same thing with aliases as well shouldn't be impossible. But it sure is ugly...


Posted May 20, 2005 15:05 UTC (Fri) by markc (guest, #4419) [Link]

Perhaps if you wrote a "fishify" inbuilt function or program to covert
bash'isms to fish'isms then folks could adopt fish on top of established
bash scripts.

I could find myself using fish instead of bash but every time I went to
write something that might be widely distributed I'd probably always stick
to bash, unless there was a reliable way to ensure that a fish script
would still work under most circumstance and play well with establish bash
scripts (like rc startup scripts for instance).


Posted May 21, 2005 10:26 UTC (Sat) by liljencrantz (guest, #28458) [Link]

The languages are close enough that this should be possible. Back in college, I wrote a Pascal to C converter for a syntax course, this should actually be easier. Of course, that converter ignored tricky bits like records and pointers, and it was never widely tested...


Posted Feb 24, 2008 12:16 UTC (Sun) by beojan (guest, #50713) [Link]

It might be incompatibl with other shells, but since I am creating a 
distribution for beginners, fish is the default login shell, whilst bash 
is the default /bin/sh.

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