diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-06 21:41:54 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-06 21:41:54 +0200 |
commit | 8b50c699652e39812024af2c34973c6359302c46 (patch) | |
tree | d56fbf1e0999617ad6c64fd5192ffe4225fd9ea6 | |
parent | 5dd1844b66908cb16f7b7e1a792a11b9780de183 (diff) | |
download | vp-8b50c699652e39812024af2c34973c6359302c46.tar.gz |
Read stdin if not a tty
-rwxr-xr-x | vp | 17 | ||||
-rwxr-xr-x | vpeval | 7 |
2 files changed, 22 insertions, 2 deletions
@@ -1,2 +1,17 @@ #!/bin/sh -exec vi +':so /usr/local/etc/vprc' "$@" `mktemp` + +VPIN= +if [ ! -t 0 ]; then + VPIN=`mktemp` + cat > "$VPIN" +fi +export VPIN + +f=`mktemp` +</dev/tty >/dev/tty vi +':so /usr/local/etc/vprc' "$@" "$f" +[ "$(wc -c "$f" | awk '{print $1}')" -eq 0 ] && rm "$f" + +if [ ! -z "$VPIN" ]; then + cat "$VPIN" + rm "$VPIN" +fi @@ -1,2 +1,7 @@ #!/bin/sh -echo "$(eval "$(sed '/^#/d')" 2>&1)" | sed 's/^/# /' +{ + if [ -z "$VPIN" ] + then eval "$(sed '/^#/d')" 2>&1 + else eval "$(sed '/^#/d')" 2>&1 <"$VPIN" + fi +} | sed 's/^/# /' |