The Fish parser treats any "$" character that is unquoted or quoted
inside double quotes as a variable reference. Unfortunately, the user
may try to use "$" in a regexp inside double quotes.  For example:

> grep -E -v "^$" myfile
fish: Did you mean (COMMAND)? In fish, the '$' character is only used
for accessing variables. To learn more about command substitution in
fish, type "help expand-command-substitution".
grep -E -v "^$" myfile
           ^

This can be achieved by using single quotes instead:
> grep -E -v '^$' myfile

But the user may not think of that.  Unfortunately, I don't see a way
to make the parser smarter in general.  So either the error checking
should be less strict, or the error message should be more general:

fish: Incorrect variable reference.  The "$" character is used for
variable reference when it is unquoted or inside double quotes (").
You can use single quotes (') instead.  To learn about variables, type
"help variables"; about variable substitution type "help
expand-command-substitution".

or

fish: Incorrect use of "$".  When the "$" character is unquoted or
inside double quotes ("), it is interpreted as a variable reference.
To avoid this, put it inside single quotes (').  To learn about
variables, type "help variables"; about variable substitution, type
"help expand-command-substitution".

I'm not sure why the command substitution part is useful.

Incidentally, a more radical idea used in YubNub solves this and
another problem: use a builtin called "var" for all variable
operations, including setting, getting and removing:
> var A --set-global hello bye
> var A
hello bye
> echo "say: (var A) now!"
say: hello bye now!
> var A --erase

This is more verbose but perhaps more intuitive, as it uses the same
syntax for setting and reading.  Also, the builtin may be easier to
remember and discover because its name is mnemonic.  It also solves
the above problem, because "$" would never be special.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to