isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

commit 4c14ca35f129012cf6bdcb6a6a84ac887be50515
parent ff50db0c2aace3513afc94aa2b4d267f67e089d2
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Mon, 25 Nov 2024 11:06:58 +0100

Activer les couleurs avec -c

isposix sans couleur
isposix -c avec couleur

Diffstat:
Disposix | 61-------------------------------------------------------------
Misposix.sh | 8+++++++-
2 files changed, 7 insertions(+), 62 deletions(-)

diff --git a/isposix b/isposix @@ -1,61 +0,0 @@ -#! /bin/sh -set -e - -red="\033[91m";green="\033[92m";blue="\033[94m";norm="\033[0m" -_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" \ - || _inform ", did you mean : $(echo "$fzcmd" | paste -s -d',') ?" -} - -usage() { - <<-. cat - Check if command or its options are posix - - isposix command [options] - - exemple : - - isposix ls - isposix ls -a - . -} - -checkoption() { - cmd="$1";option="$2" - < bdd/$cmd.html grep -Eq "<dt><b>-$option[&<].*</dt>" \ - && { _success " -$option";return 0;} \ - || { _die " -$option"; return 1;} -} - -scriptisposix=0 -while read line;do - set -- $line - cmdisposix=0 - cmd="$1";shift - if [ ! -f "bdd/$cmd.html" ];then - _cmdnotposix;cmdisposix=1 - else - _success "$cmd" - while getopts "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" opt; do - case "$opt" in - ( * ) checkoption "$cmd" "$opt" || cmdisposix=1;; - esac - done - fi - [ $cmdisposix = "0" ] \ - && _success " | is posix\n" \ - || { _die " | not posix\n";scriptisposix=1; } -done - -exit $scriptisposix - diff --git a/isposix.sh b/isposix.sh @@ -1,7 +1,7 @@ #! /bin/sh set -e -red="\033[91m";green="\033[92m";blue="\033[94m";norm="\033[0m" + _die() { printf "$red$@$norm" >&2 ; } _success() { printf "$green$@$norm" >&2; } _inform() { printf "$blue$@$norm" >&2; } @@ -37,6 +37,12 @@ checkoption() { || { _die " -$option"; return 1;} } +while getopts "c" opt; do + case "$opt" in + ( c ) red="\033[91m";green="\033[92m";blue="\033[94m";norm="\033[0m";; + esac +done + scriptisposix=0 while read line;do set -- $line