Axel Liljencrantz wrote:
Of, I have added a patch to the Darcs version of fish which changes the syntax of 'and' and 'or' to:
[infix semantics, as builtins - the previous command must be properly terminated]
You will notice in the above example that 'pwd && whoami' actually launches 'pwd &' in the background. Maybe fish should do a syntax check on the whole commandline and reject all of it instead?

After installing the most recent darcs repo fish build I think that the error message redirecting the user to "or" or "and" is great for discoverability for migrating POSIX scripters. I think it's best not to run the job in the background though - it's almost certainly not what the user intended.

But then, if you're going to be doing that parsing anyway, why not simply do the replacement on behalf of the user:
"||" becomes "; or "
"&&" becomes "; and "

OK, I already know your answer - "one syntax only", "ugly hack", etc. ;-)

But this does give me another idea - let's assume Joe User wants to implement this alias. Fish doesn't support functions with pipe symbols in their name, and the symbol doesn't occur in a valid spot for a function anyhow, so that's out of the question.

How about supporting it through the (evolving) event model though: there could be a "parser error" event, and one particular error could have type "double-pipe". The user could install a handler for the double-pipe parser error, and this handler would be given enough information to be able to replace the double-pipe in the command-line with "; or ". A little esoteric, but perhaps less objectionable to your no-configurability tastes.

Even more generically, there could be a pre-parse-commandline event that would do replacements prior to fish interpreting the commandline.

Things like that would help to make a POSIX-compatible mode for fish a possibility (activated through an entry-point function in a set of separately distributed fish functions) without disturbing your desire to avoid configurable options. It wouldn't be expected that users enable this mode by default, but it would be helpful if they e.g. want to run a POSIX script without changing shells, or want to try fish out briefly to investigate its usability features without having to learn its syntax when they already know POSIX.

--
http://members.dodo.com.au/~netocrat


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to