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

Escape wildcards in shell code #17

Closed
dolmen opened this issue Feb 5, 2016 · 2 comments
Closed

Escape wildcards in shell code #17

dolmen opened this issue Feb 5, 2016 · 2 comments

Comments

@dolmen
Copy link
Owner

dolmen commented Feb 5, 2016

The shell code generated is evaluated with eval $(angel-PS1) as indicated in the documentation.
Due to the use of $( ... ), this code is subject to wildard expansion. And we have a wildcard in the case ... esac block of the bash code.
Try this in bash:

touch 'aaaaaa)'
angel-PS1 | tee foo.bash
echo $(cat foo.bash)

=> The "*)" in the shell code is expanded.

A better demonstration of the issue:

$ echo $(echo 'an*')
angel-PS1
@dolmen
Copy link
Owner Author

dolmen commented Feb 5, 2016

Fixed in bash with 835afbf .

dolmen added a commit that referenced this issue Feb 5, 2016
As the shell code we generate is evaluated in $( ... ), it is subject to
word splitting and pathname expansion. In the code of the angel function
we have a case...esac block which has the *) entry. This 'word' was
expanded if the current directory contained a filename ending with ')'.
For example:
    touch '(aaa GH17)'
    eval $(angel-PS1)

So we use a trick to escape pathname expansion. The line:
    *)
becomes:
    ''*)
dolmen added a commit that referenced this issue Feb 5, 2016
Zsh 5.0.2 does not show the behaviour we have in bash dans dash, but we
preventively add the same fix as for the other shells.
@dolmen
Copy link
Owner Author

dolmen commented Feb 5, 2016

Zsh 5.0.2 does not seem to have yet the behaviour seen in bash and dash. But I preventively applied the fix also for that shell in 1a701be .

@dolmen dolmen closed this as completed Feb 14, 2016
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

1 participant