aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-04 11:58:03 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-04 11:58:03 +1200
commita0ca55ad53acffd2fa87ff84dfba7bccec92dfc6 (patch)
treeb428b79985af12132536f1459a9445c6eafdbf54 /bash/bashrc.d
parentCOLORFGBG too (diff)
downloaddotfiles-a0ca55ad53acffd2fa87ff84dfba7bccec92dfc6.tar.gz
dotfiles-a0ca55ad53acffd2fa87ff84dfba7bccec92dfc6.zip
Support -p option to vared
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/vared.bash17
1 files changed, 16 insertions, 1 deletions
diff --git a/bash/bashrc.d/vared.bash b/bash/bashrc.d/vared.bash
index a2066b4c..40eeee21 100644
--- a/bash/bashrc.d/vared.bash
+++ b/bash/bashrc.d/vared.bash
@@ -5,6 +5,21 @@ fi
# Edit named variables' values
vared() {
+ local opt prompt
+ local OPTERR OPTIND OPTARG
+ while getopts 'p:' ; do
+ case $opt in
+ p)
+ prompt=$OPTARG
+ ;;
+ \?)
+ printf 'bash: %s: -%s: invalid option\n'
+ "$FUNCNAME" "$opt" >&2
+ return 2
+ ;;
+ esac
+ done
+ shift "$((OPTIND-1))"
if ! (($#)) ; then
printf 'bash: %s: No variable names given\n' \
"$FUNCNAME" >&2
@@ -12,7 +27,7 @@ vared() {
fi
local name
for name in "$@" ; do
- IFS= read -e -i "${!name}" -p "$name"= -r "$name"
+ IFS= read -e -i "${!name}" -p "${prompt:-$name=}" -r -- "$name"
done
}
complete -A variable vared