Any zsh users here?
I am migrating from bash. I had a bash function that takes argument $1 as a parameter, but in zsh I get "no matches found". The function works, but I think i'm just not passing the argument as the parameter in the right way.
How do I do it?# my function
function function() { osascript /usr/local/bin/function.scpt "$1" ;}
>>61683162
Don't know if this'll help or if I'm just a moron who doesn't know what he's talking about, but $N, where N is any integer, are positional parameters and you can't assign anything to them.
>>61683239Code test
>>61683239
No you're right, it is an arglist, just like argv[] in C-ish languages. I think you're supposed to be able to access the arglist in this way.
the way it works is i call my function, and pass it parameter $1, then execute the function.
I tried changing it to $0, $1, and $2, just in case it were indexed differently, but I'm pretty sure that my first argument is $1.
by the way, the thing i am passing is an http url. in bash it just werked without any escaping, so i think zsh should be the same
>>61683295
Are you passing invalid chars or globs?
>>61683347
Yeah, Zsh is finicky and you're gonna have to escape those chars.
i found an answer here, but it's basically saying "turn of the zsh security features to make it like bash"
https://unix.stackexchange.com/questions/145214/must-pass-urls-in-quotes
how do i do it in the zsh way?
>>61683381
Set nomatch off.setopt +o nomatch
>>61683398
how can i do that within the function, then set it back after the function runs? i already tried adding statements to my function
>>61683489
It doesn't change the behaviour in any bad way, it just changes it to behave like bash.
You can trysetopt -o nomatch
to set it back to default, but it's better to just surround your inputs with quotes.