#1 Le 08/04/2020, à 12:58
- ar barzh paour
[Résolu] retour de commande man help info
voir solution post 2 et3
j'ai un soucis de retour de code quand je redirige "info" dans un fichier
ce qui me parait OK
=============================================================
info "xxx"
info: Aucune entrée de menu « xxx » dans le nœud « (dir)Top ».
echo $?
1 # ça c'est ok
=============================================================
info "printf"
echo $?
0 ça c'est ok
=============================================================
info "printf" > /tmp/res.txt
echo $?
0
le fichier res.txt contient bien le résultat
ça c'est OK
=============================================================
mais le retour suivant ne fonctionne pas comme j'espérais quand je redirige vers un fichier et que info ne trouve rien
info "xxx" > /tmp/res.txt
info: Aucune entrée de menu « xxx » dans le nœud « (dir)Top ».
echo $?
0 # retour de zéro alors que rien n'est trouvé
# et que le fichier res.txt est bien vide
ls -ails /tmp/res.txt
262683 0 -rw-r--r-- 1 jpb jpb 0 avril 8 13:38 /tmp/res.txt
==============================================================
à noter que je n'ai pas ce problème" ni pour man
man "xxx"
Aucune entrée de manuel pour xxx
echo $?
16 # non zéro
dans un fichier
man "xxx" >/tmp/res.txt
Aucune entrée de manuel pour xxx
echo $?
16 # même code d'erreur
ls -ails /tmp/res.txt
262683 0 -rw-r--r-- 1 jpb jpb 0 avril 8 13:44 /tmp/res.txt
===============================================================
ni pour help
help "xxx"
bash: help: Aucune rubrique d'aide ne correspond à « xxx ». Essayez « help help », « man -k xxx » ou « info xxx ».
echo $?
1
dans un fichier
help "xxx" >/tmp/res.txt
bash: help: Aucune rubrique d'aide ne correspond à « xxx ». Essayez « help help », « man -k xxx » ou « info xxx ».
echo $?
1
ls -ails /tmp/res.txt
262683 0 -rw-r--r-- 1 jpb jpb 0 avril 8 13:45 /tmp/res.txt
===============================================================
ma question : comment obtenir un code non zéro sur info "xxx" > fichier ????
Dernière modification par ar barzh paour (Le 08/04/2020, à 14:52)
PC : B760M DS3H DDR4, 12th Gen Intel(R) Core(TM) i3-12100, RAM DDR4 8GiB -2400 Ubuntu 20.04, 22.04, 24.04 (en test )
Portable1 : ThinkPad P50 I7-6820HQ, 16G0 Ram Ubuntu 22.04 Ubuntu 24.04 , W10-PRO( en voyage )
Portable2 : T5750 @ 2.00GHz RAM 1GiB DDR2 667 Mhz Ubuntu 20.04 ( batterie HS )
stourm a ran war bep tachenn (Angela Duval) ( Je combats sur tous les fronts )
Hors ligne
#2 Le 08/04/2020, à 13:31
- kamaris
Re : [Résolu] retour de commande man help info
Oui, c'est plutôt moche ça
Et c'est pareil quand on fait
info 'xxx' -o fichier
J'avais déjà eu un problème similaire avec les codes retour de info : info -w 'xxx' renvoie 0, alors que man -w 'xxx' renvoie 16.
Du coup, j'étais passé par
test -n "$(info -w "$pattern")" && …
que tu peux utiliser aussi :
test -n "$(info -w "$pattern")" && info "$pattern" >fichier
Dernière modification par kamaris (Le 08/04/2020, à 13:33)
Hors ligne
#3 Le 08/04/2020, à 14:50
- ar barzh paour
Re : [Résolu] retour de commande man help info
@Kamaris ok pour moi du coup mon code fonctionne
function afficher_info { # $1= le terme à chercher
if [[ -n "$1" ]]
then
echo -e "\n\nrecherche info \"$1\"" >> $fich
test -n "$(info -w "$1")"
codeinfo=$?
if [[ $codeinfo -ne 0 ]]
then
echo "pas de info pour $1 (code : $codeinfo)" >> $fich
else
info "$1" >> $fich
fi
echo -e "\nFIN DE INFO $deb_diese" >> $fich
return $codeinfo
else
return 64 # vide
fi
}
PC : B760M DS3H DDR4, 12th Gen Intel(R) Core(TM) i3-12100, RAM DDR4 8GiB -2400 Ubuntu 20.04, 22.04, 24.04 (en test )
Portable1 : ThinkPad P50 I7-6820HQ, 16G0 Ram Ubuntu 22.04 Ubuntu 24.04 , W10-PRO( en voyage )
Portable2 : T5750 @ 2.00GHz RAM 1GiB DDR2 667 Mhz Ubuntu 20.04 ( batterie HS )
stourm a ran war bep tachenn (Angela Duval) ( Je combats sur tous les fronts )
Hors ligne