[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible bug but looking for help before bothering a dev
|
From: |
Laurent Lyaudet |
|
Subject: |
Re: Possible bug but looking for help before bothering a dev |
|
Date: |
Wed, 4 Mar 2026 20:35:35 +0100 |
Le mer. 4 mars 2026 Ă 20:32, Laurent Lyaudet
<laurent.lyaudet@gmail.com> a écrit :
>
> Le mer. 4 mars 2026 à 20:14, Jeffrey Walton <noloader@gmail.com> a écrit :
> >
> >
> >
> > On Wed, Mar 4, 2026 at 2:01 PM Laurent Lyaudet <laurent.lyaudet@gmail.com>
> > wrote:
> >>
> >> I also want to add that I found a flaw in some variant of the
> >> suggestion by Martin.
> >>
> >> not_funny1(){
> >> # The {} syntax works for return.
> >> echo "$1" | {
> >> [[ "$1" == "hahaha" ]]
> >> return $?
> >> }
> >> }
> >>
> >> not_funny2(){
> >> # The {} syntax doesn't work for variables affectation.
> >> declare -i LFBFL_i_result=0
> >> echo "$1" | {
> >> [[ "$1" == "hahaha" ]]
> >> LFBFL_i_result=$?
> >> }
> >> # shellcheck disable=SC2248
> >> return ${LFBFL_i_result}
> >> }
> >>
> >> Here is what I obtain:
> >>
> >> $ not_funny1 hahaha && echo "abcd"
> >> abcd
> >> $ not_funny1 hihihi && echo "abcd"
> >> $ not_funny2 hahaha && echo "abcd"
> >> abcd
> >> $ not_funny2 hihihi && echo "abcd"
> >> abcd
> >>
> >> Surprisingly, it behaves like a normal subshell
> >>
> >> not_funny3(){
> >> # The () syntax works for return.
> >> echo "$1" | (
> >> [[ "$1" == "hahaha" ]]
> >> return $?
> >> )
> >> }
> >>
> >> not_funny4(){
> >> # The () syntax doesn't work for variables affectation.
> >> declare -i LFBFL_i_result=0
> >> echo "$1" | (
> >> [[ "$1" == "hahaha" ]]
> >> LFBFL_i_result=$?
> >> )
> >> # shellcheck disable=SC2248
> >> return ${LFBFL_i_result}
> >> }
> >>
> >> $ not_funny3 hahaha && echo "abcd"
> >> abcd
> >> $ not_funny3 hihihi && echo "abcd"
> >> $ not_funny4 hahaha && echo "abcd"
> >> abcd
> >> $ not_funny4 hihihi && echo "abcd"
> >> abcd
> >>
> >> The case not_funny2 seems a bug to me.
> >> Do you think the same?
> >
> >
> > $ cat funny.sh
> >
> > #!/usr/bin/env bash
> >
> > not_funny1(){
> > # The {} syntax works for return.
> > echo "$1" | {
> > [[ "$1" == "hahaha" ]]
> > return $?
> > }
> > }
> >
> > not_funny2(){
> > # The {} syntax doesn't work for variables affectation.
> > declare -i LFBFL_i_result=0
> > echo "$1" | {
> > [[ "$1" == "hahaha" ]]
> > LFBFL_i_result=$?
> > }
> > # shellcheck disable=SC2248
> > return ${LFBFL_i_result}
> > }
> >
> > Then, Shellcheck. Lines 16 and 19 are from not_funny2:
> >
> > $ shellcheck funny.sh
> >
> > In funny.sh line 16:
> > LFBFL_i_result=$?
> > ^------------^ SC2030 (info): Modification of LFBFL_i_result is local
> > (to subshell caused by pipeline).
> >
> >
> > In funny.sh line 19:
> > return ${LFBFL_i_result}
> > ^---------------^ SC2031 (info): LFBFL_i_result was modified in a
> > subshell. That change might be lost.
> >
> > For more information:
> > https://www.shellcheck.net/wiki/SC2030 -- Modification of LFBFL_i_result
> > is...
> > https://www.shellcheck.net/wiki/SC2031 -- LFBFL_i_result was modified in
> > a ...
>
> Well my computer is hacked.
> And someone hacked shellcheck in particular.
> Below is the commands sequence in my shell:
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> source miscellaneous/funny.sh
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny build_and_checks_dependencies/lines_filters.libr.sh
> ha?
> Here it is ok.
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny1 hahaha && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny1 hihihi && echo "abcd"
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny2 hahaha && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny2 hihihi && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> shellcheck --enable=all miscellaneous/funny.sh
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny3 hahaha && echo "abcd"
> not_funny3 : commande introuvable
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> source miscellaneous/funny.sh
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny3 hahaha && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny3 hihihi && echo "abcd"
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny4 hahaha && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> not_funny4 hihihi && echo "abcd"
> abcd
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
> shellcheck --enable=all miscellaneous/funny.sh
>
> In miscellaneous/funny.sh line 77:
> LFBFL_i_result=$?
> ^------------^ SC2030 (info): Modification of LFBFL_i_result is
> local (to subshell caused by (..) group).
>
>
> In miscellaneous/funny.sh line 80:
> return ${LFBFL_i_result}
> ^---------------^ SC2031 (info): LFBFL_i_result was modified
> in a subshell. That change might be lost.
>
> For more information:
> https://www.shellcheck.net/wiki/SC2030 -- Modification of LFBFL_i_result
> is...
> https://www.shellcheck.net/wiki/SC2031 -- LFBFL_i_result was modified in a
> ...
>
> For more information:
> https://www.shellcheck.net/wiki/SC2030 -- Modification of LFBFL_i_result
> is...
> https://www.shellcheck.net/wiki/SC2031 -- LFBFL_i_result was modified in a
> ...
> laurent@laurent-GL73-8SD:~/Données/MesProjetsGit/DevOrSysAdminScripts$
>
> As you can there is an intermediate
> shellcheck --enable=all miscellaneous/funny.sh
> that returned nothing.
Some of the crackers that play fun with me must have thought that
adding a kill switch on shellcheck was a good idea to make me lose my
time.
As you can see above,
not_funny2 was already in the file when doing first shellcheck of the
extract of my shell commands.
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Jeffrey Walton, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Jeffrey Walton, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev,
Laurent Lyaudet <=
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Chet Ramey, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Chet Ramey, 2026/03/04
- Re: Possible bug but looking for help before bothering a dev, Laurent Lyaudet, 2026/03/04
Re: Possible bug but looking for help before bothering a dev, Greg Wooledge, 2026/03/04