[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do we get state of a flag in set -o ...
From: |
alex xmb ratchev |
Subject: |
Re: How do we get state of a flag in set -o ... |
Date: |
Tue, 11 Jul 2023 23:15:52 +0200 |
On Tue, Jul 11, 2023, 22:05 Greg Wooledge <greg@wooledge.org> wrote:
> On Wed, Jul 12, 2023 at 02:54:10AM +0700, Budi wrote:
> > How do we get state of a flag in set -o ... that has no directly alias
> > set [-+] , e.g.
> > set -o posix
> > or
> > set -o vi
> > ?
> >
> > not, e.g. set -o errexit , as it can be retrieved by echo $-
>
> Parse the output of "set -o".
>
i was trying some simple code but fatally failed
+ ret
++ set -o
+ a=('allexport off
braceexpand on
emacs on
errexit off
errtrace off
functrace off
hashall on
histexpand on
history on
ignoreeof off
interactive-comments on
keyword off monitor
on noclobber
off noexec off
noglob off
nolog off
notify off
nounset off
onecmd off
physical off
pipefail off
posix off
privileged off
verbose off
vi off
xtrace on')
+ declare -gA a
+ declare -p a
declare -A a=([$'allexport \toff\nbraceexpand \ton\nemacs
\ton\nerrexit \toff\nerrtrace \toff\nfunctrace
\toff\nhashall \ton\nhistexpand \ton\nhistory
\ton\nignoreeof \toff\ninteractive-comments\ton\nkeyword
\toff\nmonitor \ton\nnoclobber \toff\nnoexec
\toff\nnoglob \toff\nnolog \toff\nnotify
\toff\nnounset \toff\nonecmd \toff\nphysical
\toff\npipefail \toff\nposix \toff\nprivileged
\toff\nverbose \toff\nvi \toff\nxtrace
\ton']="" )
~ $ IFS=$' \t\n' ; ret() { declare -gA a=( $( set -o ) ) ; declare -p a ; }
; sett() { declare -A m=( off + on - ) ; declare -ga args=( set ) ; for z
in ${!a[@]} ; do declare -n "v=a[$z]" "mm=m[$v]" ; echo args+= ${mm}o $z ;
done ; echo set "${args[@]}" ; } ; ret
i didnt try without declare but ill try
why s that not split
might be declare issue
>
- How do we get state of a flag in set -o ..., Budi, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Budi, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Greg Wooledge, 2023/07/11
- Re: How do we get state of a flag in set -o ...,
alex xmb ratchev <=
- Re: How do we get state of a flag in set -o ..., alex xmb ratchev, 2023/07/11
- Re: How do we get state of a flag in set -o ..., alex xmb ratchev, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Greg Wooledge, 2023/07/11
- Re: How do we get state of a flag in set -o ..., alex xmb ratchev, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Greg Wooledge, 2023/07/11
- Re: How do we get state of a flag in set -o ..., alex xmb ratchev, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Greg Wooledge, 2023/07/11
- Re: How do we get state of a flag in set -o ..., alex xmb ratchev, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Grisha Levit, 2023/07/11
- Re: How do we get state of a flag in set -o ..., Greg Wooledge, 2023/07/11