vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 5da6061ae3449a38c20918057e2cd3cb3ac43fe0
parent 80cfd234c4d234aa2e4c6cb2d198da47938a6abc
Author: Tom Schwindl <schwindl@posteo.de>
Date:   Sat, 20 Aug 2022 12:30:24 +0000

make vis-open and vis-complete more POSIX compliant

This commit combines 3 commits:

- vis-open: `local' is not part of POSIX
  (Author: Tom Schwindl <schwindl@posteo.de>)

- More POSIXisation.
  (Author: Matěj Cepl <mcepl@cepl.eu>)

- Clean up of vis-complete as well.
  (Author: Matěj Cepl <mcepl@cepl.eu>)

Diffstat:
Mvis-complete | 2+-
Mvis-open | 8+++-----
2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/vis-complete b/vis-complete @@ -61,5 +61,5 @@ else sed "s|^$(dirname $XPATTERN)/||" fi | vis-menu -b | - sed "s|^$(basename $PATTERN)$(echo $PATTERN | tail -c 2 | fgrep /)||" | + sed "s|^$(basename $PATTERN)$(echo $PATTERN | tail -c 2 | grep -F /)||" | tr -d '\n' diff --git a/vis-open b/vis-open @@ -9,9 +9,7 @@ VIS_MENU_PROMPT="" ALLOW_AUTO_SELECT=1 wrap_dirs() { - local o - - while read o + while read -r o do [ -d "$o" ] && printf "%s/\n" "$o" || printf "%s\n" "$o" done @@ -45,7 +43,7 @@ done # At this point, all the remaining arguments should be the expansion of # any globs that were passed on the command line. -if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then +if [ $# -eq 1 ] && [ "$ALLOW_AUTO_SELECT" = 1 ]; then # If there were globs on the command-line, they've expanded to # a single item, so we can just process it. @@ -55,7 +53,7 @@ if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then # full list, even if it's just an empty directory. cd "$1" IFS=$NL # Don't split ls output on tabs or spaces. - exec "$0" -p "$VIS_MENU_PROMPT" -f .. $(ls -1) + exec "$0" -p "$VIS_MENU_PROMPT" -f .. "$(ls -1)" else # We've found a single item, and it's not a directory, # so it must be a filename (or file-like thing) to open,