Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

commande précédente dans un script

1 réponse
Avatar
Antoine
Salut,

Sous zsh, comment r=E9cup=E9rer la derni=E8re commande tap=E9e dans le
terminal?
En fait, je voudrais me prot=E9ger de moi m=EAme en emp=EAchant un `rm`
apr=E8s un `tar tf` ou un `unrar t`
Le script =E9tant un processus diff=E9rent, je crains de ne pas avoir aces
a l'historique du shell parent.
Merci!

1 réponse

Avatar
Stephane CHAZELAS
2011-06-8, 06:11(-07), Antoine:
Salut,

Sous zsh, comment récupérer la dernière commande tapée dans le
terminal?
En fait, je voudrais me protéger de moi même en empêchant un `rm`
après un `tar tf` ou un `unrar t`
Le script étant un processus différent, je crains de ne pas avoir aces
a l'historique du shell parent.



$ preexec() { PREVCMD=$last_cmd last_cmd=$1; export PREVCMD; }
$ echo test
test
$ sh -c 'echo $PREVCMD'
echo test

--
Stephane