• # utilisation en framework bash

    Posté par (site web personnel) . En réponse au journal mr_freeze.sh un utilitaire de capture de commandes paramétrée. Évalué à 1.

    Peut s'utiliser en librairie shell comme suit:

    . ./mr_freeze.sh 
    

    ensuite :

    A=badass freeze input 
    

    Ce qui donne :

    ✍️ recording: uname -a #immutable
    ✍️ recording: [ -n "$PROD" ] && echo "ok" || echo "ko" # mutable according to env variable
    ✍️ recording: echo ${B:-$(date)} # mutable or not
    ✍️ recording: slmdkfmlsfs # immutable
    ✍️ recording: du -sh #immutable (kof kof)
    ✍️ recording: ssh "$A" 'uname -a'
    ✅ [input] recorded. Use [bash thaw "replay_input" ] to replay
    A=petiot thaw replay_input 
    

    donnant :

    👌 uname -a #immutable
    👌 [ -n "$PROD" ] && echo "ok" || echo "ko" # mutable according to env variable
    🔥 echo ${B:-$(date)} # mutable or not 
    @@ -1 +1 @@
    -mar. 11 nov. 2025 14:20:07 CET
    +mar. 11 nov. 2025 14:20:12 CET
    👌 slmdkfmlsfs # immutable
    👌 du -sh #immutable (kof kof)
    🔥 ssh "$A" 'uname -a' 
    @@ -1 +1 @@
    -Linux badass 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
    +FreeBSD petiot 14.3-RELEASE-p5 FreeBSD 14.3-RELEASE-p5 GENERIC amd64
    $ A=petiot B=1 thaw replay_input
    👌 uname -a #immutable
    👌 [ -n "$PROD" ] && echo "ok" || echo "ko" # mutable according to env variable
    🔥 echo ${B:-$(date)} # mutable or not 
    @@ -1 +1 @@
    -mar. 11 nov. 2025 14:20:07 CET
    +1
    👌 slmdkfmlsfs # immutable
    👌 du -sh #immutable (kof kof)
    🔥 ssh "$A" 'uname -a' 
    @@ -1 +1 @@
    -Linux badass 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
    +FreeBSD petiot 14.3-RELEASE-p5 FreeBSD 14.3-RELEASE-p5 GENERIC amd64

    Maintenant il serait bien que je m'y colle sérieusement et positionne le return pour que ces fonctions retournent un code de réussite/erreurs