[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a sentense about set -k .. ?
From: |
alex xmb ratchev |
Subject: |
Re: a sentense about set -k .. ? |
Date: |
Fri, 30 Jun 2023 05:46:16 +0200 |
On Fri, Jun 30, 2023, 05:33 Lawrence Velázquez <vq@larryv.me> wrote:
> On Thu, Jun 29, 2023, at 10:57 PM, Greg Wooledge wrote:
> > You need to use a
> > command that actually *uses* the yo environment variable.
> >
> > unicorn:~$ awk 'BEGIN {print ENVIRON["yo"]}' yo=7
> >
> > unicorn:~$ set -k
> > unicorn:~$ awk 'BEGIN {print ENVIRON["yo"]}' yo=7
> > 7
>
it is parsed , as var , so it also goes away from the args list for that
reason , alike nullglob
As a corollary, "yo=7" is no longer passed to the command as an
> argument:
>
> bash-5.2$ set -x
> bash-5.2$ awk 'END { print "yo is", yo }' yo=7 </dev/null
> + awk 'END { print "yo is", yo }' yo=7
> yo is 7
> bash-5.2$ set -k
> + set -k
> bash-5.2$ awk 'END { print "yo is", yo }' yo=7 </dev/null
> + yo=7
> + awk 'END { print "yo is", yo }'
> yo is
>
also we used gawk ENVIRON [ "yo" ] ,
your 'yo' is normal awkvar
.. i yet couldnt figure out the awk ish var=blabla some write in their man
pages
only know -vvar=blabla , and inside , ENVIRON
> I've never seen anyone use this set -k "feature". I cannot see any good
> > reason for it to continue to exist. Looks extremely legacy-ish.
>
> Even POSIX didn't take it!
>
> The following "set" options were omitted intentionally with the
> following rationale:
>
> -k
> The -k flag was originally added by the author of the
> Bourne shell to make it easier for users of pre-release
> versions of the shell. In early versions of the Bourne
> shell the construct "set name=value" had to be used to
> assign values to shell variables. The problem with -k is
> that the behavior affects parsing, virtually precluding
>
' precluding ' meaning ' unable to write compilers ' ?
writing any compilers. To explain the behavior of -k, it
> is necessary to describe the parsing algorithm, which is
> implementation-defined. For example:
>
> set -k; echo name=value
>
> and
>
> set -k
> echo name=value
>
> behave differently. The interaction with functions is
> even more complex. What is more, the -k flag is never
> needed, since the command line could have been reordered.
>
what the noob nonsense
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set
>
> --
> vq
>
>
Re: a sentense about set -k .. ?, Kerin Millar, 2023/06/29