I'm teaching myself to write zsh functions and I'm stumped right away with a string error I don't understand. I have this function:
function copyToDrafts() {
print($1)
}
in my command line editor (Terminal) I type:
copyToDrafts "test"
and receive this error:
copyToDrafts:1: missing end of string
I couldn't find any explanation on the error message and can't see anything wrong with what I am passing, though obviously something is wrong. Any help would be appreciated.
The parentheses are not part of the syntax; they are interpreted as introducing a glob qualifier on the pattern print
. After parameter expansion, the pattern to be evaluated is
print(test)
with the following glob qualifiers:
t
- match files named print
that have their sticky bits sete
execute a shell command. s
acts as the delimiter, but there is no "closing" s
, which produces the observed error.You simply need to drop the parentheses.
copyToDrafts () {
print $1
}