feat(zkbd): allow zkbd to generate config in a custom directory#161
feat(zkbd): allow zkbd to generate config in a custom directory#161sph432 wants to merge 6 commits intozsh-users:masterfrom
Conversation
|
|
||
| zkbd=${ZDOTDIR:-$HOME}/.zkbd | ||
| zparseopts -D -F -- d:=rawdir || return 1 | ||
| [[ -n "$rawdir" ]] && zkbd="${rawdir[2]}" |
There was a problem hiding this comment.
this can be simplified to zkbd=${rawdir[2]:-${ZDOTDIR:-$HOME}/.zkbd}
arguably it should check to see if an empty argument is given, since it could be the result of an error like a mistyped variable
i also don't think it should just silently ignore it if the directory doesn't exist
so maybe
if (( $#rawdir )); then
zkbd=${rawdir[2]}
else
zkbd=${ZDOTDIR:-$HOME}/.zkbd
fi
mkdir will catch the empty argument case
There was a problem hiding this comment.
simplification accepted in 5de6025
zparseopts | return 1 handles the empty argument case just fine, even when explicitly specified:
% x -d''
x:zparseopts:1: missing argument for option: -d
regarding the 'accidental' mkdir, it happens with the default case as well, so maybe a warning about it in the docs would be more adequate: 799720f
There was a problem hiding this comment.
that's a missing argument, not an empty one. -d'' is the same thing as just -d
% () { local d; zparseopts -F - d:=d && print ok } -d ''
ok
in that case it will just silently use the default instead of alerting you to the mistake
not sure what you mean about accidental mkdir, i wasn't objecting to the directory being created. but not opposed to your clarification either
|
|
||
| zkbd=${ZDOTDIR:-$HOME}/.zkbd | ||
| zparseopts -D -F -- d:=rawdir || return 1 | ||
| [[ -n "$rawdir" ]] && zkbd="${rawdir[2]}" |
There was a problem hiding this comment.
simplification accepted in 5de6025
zparseopts | return 1 handles the empty argument case just fine, even when explicitly specified:
% x -d''
x:zparseopts:1: missing argument for option: -d
regarding the 'accidental' mkdir, it happens with the default case as well, so maybe a warning about it in the docs would be more adequate: 799720f
No description provided.