Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Two different zsh sessions handle $* differently



On 8/23/17, Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> This is broken.  If you invoke >> j f* << then the argument list passed
> to the function is already expanded.  In this case, you want an alias
> instead.

Thanks for pointing this out. I knew it didn't work as intended and I
was pondering why's that the case -- I had it as an alias originally
when things worked and then started to functionize things. Wasn't using
the alias much at the time so the regression went largely unnoticed.

> Which python3 is used?  Is it the same one in both environments, or is
> pyenv or equivalent using shell environment variables or .pyenv-version
> files to dispatch to a different interpreter, with one having sys.argv
> getting mangled in the start-up files?

Both examples run on home directory, the env points to the same python3
version 3.4.5, no virtualenvs.

> Is os.environ[PYTHONSTARTUP] defined, causing logic to happen before
> your code sees sys.argv?

Nothing defined there.

> Do you have any suffix or global aliases defined in the older zsh
> instance?  `alias -s`, `alias -g`?

No, nothing.

> You can use `setopt xtrace` (or `set -x`) to have zsh emit diagnostics
> of what it's doing, so if you do that before invoking `j` then you might
> see something different in the two environments.

This shows something alright:

    (~) j Test. ABC ABC ABC.
    +preexec:0> print -Pn '\e]2;zsh: %~\a'
    +zsh:1165> j Test. ABC ABC ABC.
(*) +j:0> journal.py Test.ABCABCABC.
    argv ['Test.']
    +precmd:0> print -Pn '\e]2;zsh: %~\a'
    +zsh:1166> parse_git_branch
    +parse_git_branch:1> git branch --no-color
    +parse_git_branch:2> sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'

The starred line doesn't look correct. With a fresh session the same
line goes like this:

    +j:0> journal.py 'Test. ABC ABC ABC.'

Now I'm not sure what happens. The faulty one strips whitespace and
concatenates, (there doesn't seem to be nulls or anything separating the
arguments) yet python sees only a part of the argument.

Hope this helps.

BR,
-- Mikael



Messages sorted by: Reverse Date, Date, Thread, Author