mirror of
https://github.com/ryantm/agenix.git
synced 2024-11-25 02:58:30 +03:00
add fallback behavior to editor
This commit is contained in:
parent
f6291c5935
commit
08c95b98a1
1 changed files with 11 additions and 1 deletions
|
@ -157,7 +157,17 @@ function edit {
|
||||||
|
|
||||||
[ ! -f "$CLEARTEXT_FILE" ] || cp "$CLEARTEXT_FILE" "$CLEARTEXT_FILE.before"
|
[ ! -f "$CLEARTEXT_FILE" ] || cp "$CLEARTEXT_FILE" "$CLEARTEXT_FILE.before"
|
||||||
|
|
||||||
[ -t 0 ] || EDITOR='cp /dev/stdin'
|
if [ ! -t 0 ]; then
|
||||||
|
EDITOR='cp /dev/stdin'
|
||||||
|
else
|
||||||
|
COMMON_EDITORS=("${EDITOR}" "vim" "vi" "nvim" "nano")
|
||||||
|
for e in "${COMMON_EDITORS[@]}"; do
|
||||||
|
if command -v "$e" &> /dev/null; then
|
||||||
|
EDITOR="$e"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
$EDITOR "$CLEARTEXT_FILE"
|
$EDITOR "$CLEARTEXT_FILE"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue