Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
commit 6cef3fc6bf13d40687c885ad356921a97d89d59d parent 01f2531df55cc1a187a93741e08310ed3f4c37f2 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Sun, 24 Nov 2024 23:03:12 +0100 Revu de la recherche fuzzy de commande Abandon de la demande interactive Plus simple Meilleur affichage Diffstat:
M | isposix | | | 18 | +++++++----------- |
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/isposix b/isposix @@ -6,19 +6,15 @@ _die() { printf "$red$@$norm" >&2 ; } _success() { printf "$green$@$norm" >&2; } _inform() { printf "$blue$@$norm" >&2; } _cmdnotposix() { + _die "$cmd not posix" if command -V fzy 2>&1 > /dev/null;then fzcmd=$(find bdd -name '*.html' | xargs -I{} basename {} | sed 's/\.html$//' | fzy -e "$cmd" | head -n3) fi - [ -z "$fzcmd" ] && { _die "$cmd"; return 1;} - if [ -t 0 ];then - _inform "$cmd appears not to be posix, did you mean : $norm" - cmd=$(echo "$fzcmd" | fzy) - else - _inform "$cmd appears not to be posix, did you mean :\n$(echo "$fzcmd" | paste -s -d' or ')" - return 1 - fi + [ -z "$fzcmd" ] \ + && _die "$cmd" \ + || _inform ", did you mean : $(echo "$fzcmd" | paste -s -d',') ?" } usage() { @@ -47,7 +43,7 @@ while read line;do cmdisposix=0 cmd="$1";shift if [ ! -f bdd/$cmd.html ];then - _cmdnotposix || cmdisposix=1 + _cmdnotposix;cmdisposix=1 else _success "$cmd" while getopts "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" opt; do @@ -57,8 +53,8 @@ while read line;do done fi [ $cmdisposix = "0" ] \ - && _success " : is posix\n" \ - || { _die " : not posix\n";scriptisposix=1; } + && _success " | is posix\n" \ + || { _die " | not posix\n";scriptisposix=1; } done < /dev/stdin exit $scriptisposix