help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: i cant see whats the issue, .. ps1 + propt command + date


From: Greg Wooledge
Subject: Re: i cant see whats the issue, .. ps1 + propt command + date
Date: Sat, 25 Sep 2021 15:20:14 -0400

On Sat, Sep 25, 2021 at 09:09:56PM +0200, Alex fxmbsw7 Ratchev wrote:
> alias s='_s=$( declare -p 2>&- IFS ) ' r='eval "${_s:-unset -v IFS}" '
> now=$EPOCHREALTIME s IFS=. now2=( $now ) r ; declare -p now2
> bash: declare: now2: not found

Well, this is as expected.  You're doing this:

unicorn:~$ bash --norc
bash-5.1$ array=(1 2) eval true
bash-5.1$ declare -p array
bash: declare: array: not found

In other words, your assignments are only temporary variables for the
duration of the eval command.

Your magic "alias expansion to an assignment in the middle of a stream
of assignments" no longer works when one of the aliases expands to
be an actual command (eval), instead of an assignment.

Of note, when bash runs in POSIX mode, temporary assignemnts for the
duration of *certain* special builtin commands become no longer
temporary:

unicorn:~$ bash --norc --posix
bash-5.1$ array=(1 2) eval true
bash-5.1$ declare -p array
declare -x array="(1 2)"

I don't know whether this helps you, but it seems related, and you
might want to have this new toy that can help you break more things.
You can blame POSIX for this particular piece of nonsense.  Bash doesn't
do it by default.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]