Proper Variable Expansion
See original GitHub issueCurrently, dotbot uses os.path.expandvars.
However, in some cases, it may be desireable to follow proper shell parameter substitution. (see: the related manual)
Here is an example usage: I want my zshrc to work. Some systems may define $ZDOTDIR
to be $XDG_DATA_HOME/zsh
, some may leave it undefined.
The typical solution would be to use ${ZDOTDIR:-$HOME}/.zshrc
as the install location. However, without parameter substitution, there is no way to achieve this.
Issue Analytics
- State:
- Created 8 years ago
- Comments:27 (13 by maintainers)
Top Results From Across the Web
Shell Parameter Expansion (Bash Reference Manual) - GNU.org
Bash uses the value formed by expanding the rest of parameter as the new parameter ; this is then expanded and that value...
Read more >Variables and Parameters in the Korn Shell - InformIT
Variable Expansion. Variable expansion is the term used for the ability to access and manipulate values of variables and parameters.
Read more >An introduction to parameter expansion in Bash
Get started with this quick how-to guide on expansion modifiers that transform Bash variables and other parameters into powerful tools ...
Read more >Variables and Expansions - The Bash Guide
Parameters can be expanded to inline their data into a command's arguments. Parameter expansion is done by prefixing the variable name with a...
Read more >3.4. Shell expansion
Shell variables are allowed as operands; parameter expansion is performed before the expression is evaluated. Within an expression, shell variables may also be ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI there would definitely be more projects that could use a way to use a POSIX compatible variable substitution, most of the time the main reason is being able to define a default value. Example of a project that’s looking for a solution to this docker/compose#1377
I’d prefer to write an implementation from scratch in pure Python.
For reference, here’s the implementation of
posixpath.expandvars
from Python 3.4:So it’s not way too complicated, but it’s not super simple either.