Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with aliases when option value contains spaces #316

Closed
kiil opened this issue May 11, 2023 · 3 comments
Closed

Problem with aliases when option value contains spaces #316

kiil opened this issue May 11, 2023 · 3 comments

Comments

@kiil
Copy link

kiil commented May 11, 2023

This works

sh-5.1$ zk new --title "one two"

But the following does not:

Config:

[alias]
n = "zk new $@"

Command and error:

sh-5.1$ zk n --title "one two"
zk: error: new note: two: directory not found

It seems when using an alias that a value containing spaces, even within quotation marks, is interpreted as separate arguments.

I have this in env:

SHELL=/usr/bin/sh
ZK_SHELL=/usr/bin/sh
@kiil
Copy link
Author

kiil commented May 11, 2023

This can be solved like so:

[alias]
n = 'zk new "$@"'

but not sure if that should not be the standard?

@mickael-menu
Copy link
Member

I think it depends on your shell. I have the same issue with sh and bash but not with zsh.

From what I gather here and there, it seems expected to wrap $@ in quotes. As zk is forwarding the alias to the shell as if it was run in a shell script, I don't think it should be too smart and auto-wrap $@. That might be unexpected and break other use cases.

It could be worth mentioning in the documentation though.

@kiil
Copy link
Author

kiil commented May 11, 2023

That makes sense.

Maybe just a note near this bullet

- expand arguments with $@ or $*

in https://github.com/mickael-menu/zk/blob/main/docs/config-alias.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants