Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Avoiding the zshells intelligence...in one case



On 01/24/2017 12:42 AM, Ray Andrews wrote:
> On 23/01/17 06:48 PM, Eric Cook wrote:
>>
>> That the point of having single quotes, so nothing within them would be treated syntactically.
>> This thread is just another plead at being even more lazy, to not have remember to use an
>> option/syntax to treat a string literally.
>>
> Except that that doesn't work with command line arguments nor with things like:
> 
Except that it does.
> $ alias junk='echo $path'
> 
> $ alias wense='whence -m "$1"'

And does so during both of those alias definitions, you may be confusing what happens
during the definition of the alias and what happens during the execution of the alias.

Running:
% alias -L

Will show you that both alias were defined exactly as you inputted them, because the single
quotes prevented the expansions

And ignoring the expansions of the commandline, the original poster used an url that contains
an ampersand; & isn't an expansion, just other shell syntax that a noglob-like option or bart's
current attempts will not be able to disable.

% curl -s http://site?param&disown
Can be a legal site url, but could also be meant as a curl command to be ran in the background and
disown that process. short of reading the user's mind how would you make it easier?
prepending noglob is already two more characters than '', then you would need an `nosyntax' like
command to deactivate &.

I get that shells, unlike other programming languages are used far more interactively and that
less typing is normally always good. But in nearly every other programming language if you don't
want the syntax/metacharacters to be treated specially, you escape/quote them correctly.

I just don't see how remembering to use an alias/option is less inconvenient than remembering to use
single quotes on strings with questionable characters.

hell, with recent versions of zsh with bracketed-paste you could copy and paste this entire email
into your shell, invoke the quote-line widget, then prefix print -r -- and have a command that will
work anywhere regardless of the options set (rcquotes being the sole exception) or alias/functions
that the user may have.




Messages sorted by: Reverse Date, Date, Thread, Author