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 14:58:20 -0400

On Sat, Sep 25, 2021 at 08:25:59PM +0200, Alex fxmbsw7 Ratchev wrote:
> ++ prptnow=1632594230.535965
> +++ declare -p IFS
> ++ __savedIFS='declare -- IFS=$'\'' \t\n'\'''
> ++ IFS=.
> ++ prptnow2='(1632594230.535965)'

I don't know why you're making your life so incredibly difficult.  You
could use the ${now#*.} and ${now%.*} expansions as I showed before, and
this would all be a thing of the past.

If you still think there's a bug in bash's alias expansions, it would
help enormously if you could write a simple recipe for how to produce
the bug.  "Run these 3 commands.  The output is ___.  It should be ____."

Anyway, here's what I get when I attempt something similar to your setup:

unicorn:~$ bash
unicorn:~$ alias saveIFS='qq=qq '
unicorn:~$ x=y now=123.456 saveIFS IFS=. array=( $now )
unicorn:~$ declare -p x now qq array
declare -- x="y"
declare -- now="123.456"
declare -- qq="qq"
declare -a array=([0]="123" [1]="456")

Or another try with two aliases:

unicorn:~$ 
exit
unicorn:~$ bash
unicorn:~$ alias saveIFS='_save="$IFS" '
unicorn:~$ alias restoreIFS='IFS="$_save" '
unicorn:~$ now=123.456 saveIFS IFS=. array=( $now ) restoreIFS
unicorn:~$ declare -p now array
declare -- now="123.456"
declare -a array=([0]="123" [1]="456")

I guess that's ... correct?  Maybe?  Is that what you expected to see?
I honestly can't even tell.  Your "alias expansion to an assignment
(with trailing whitespace) in the middle of an assignment so that the
syntax is completely different from what it looks like" construct is
so incredibly arcane, cryptic and obtuse that I have no idea what is
supposed to be happening.

Do you get something different?  If so, what do you get?

Can you show us a terminal session INCLUDING SHELL PROMPTS which starts
from a vanilla interactive bash instance, with NOTHING being brought
in from dot files, which shows behavior that you believe is wrong?
Set up the aliases and the variables, and then run the commands that
produce the output you don't like.  Then paste the whole thing into an
email.

If the erroneous output only happens when you have things stuffed into
PROMPT_COMMAND or PS1 or DEBUG traps, and not when you type normal
commands into a normal shell, then that's also important information.
In that case, show us a vanilla bash session in which you set the aliases
and then set the PROMPT_COMMAND variable and so on.  Don't bring it in
from a dot file, because that's too hard for us to understand.  We can't
SEE it.  We need to be able to see it.

Use "bash --norc" if you have to, to get a clean starting point.



reply via email to

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