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

${@:0:1} evaluates to ${@:0} #688

Closed
Crestwave opened this issue Apr 6, 2020 · 1 comment
Closed

${@:0:1} evaluates to ${@:0} #688

Crestwave opened this issue Apr 6, 2020 · 1 comment

Comments

@Crestwave
Copy link
Contributor

osh$ set a b c
osh$ echo "${@:0:1}"
osh a b c
osh$ echo "${@:0:2}"
osh a
$ set a b c
$ echo "${@:0:1}"
bash
$ echo "${@:0:2}"
bash a

This was found while toying around, not from a real script. I was testing if ${@::1} would return $1 or $0, as the Bash manual says "Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default." but ${@::1} evaluates to $0, anyway. :/

andychu pushed a commit that referenced this issue Apr 6, 2020
I made the difference between @ and array more obvious in the code.

Addresses issue #688.
@andychu
Copy link
Contributor

andychu commented Apr 6, 2020

Good catch, thanks for testing! I fixed this and simplified the code a bit.

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

No branches or pull requests

2 participants