zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: Mikael Puhakka <mr.progo@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Two different zsh sessions handle $* differently
Date: Wed, 23 Aug 2017 15:17:39 -0400	[thread overview]
Message-ID: <20170823191739.GA35723@tower.spodhuis.org> (raw)
In-Reply-To: <CAD1ad9bLy7cV8JByJcLg91ms1Eu27VDVQa8RA9H2Yf-tuBp4hA@mail.gmail.com>

On 2017-08-22 at 20:22 +0300, Mikael Puhakka wrote:
>     (~) whence -f j
>     j () {
>         noglob journal.py "$*"
>     }

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.  Then you can either have `journal.py` do
  ' '.join(sys.argv[1:])
for you, or still use a function to join things and use an
alias/function combination.  In your shoes, I'd have Python join the
parameters and _just_ use an alias.

Aliases happen before glob expansion and dispatch.  Functions are
invoked after determining their parameter list, too late for `noglob`
inside the function to help.

    # python script looks in all sys.argv[1:] :
    alias j='command journal.py'
or:
    # python script just looks at argv[1] :
    function f_j { journal.py "$*"; }
    alias j='noglob f_j'

>     (~) head -n5 /home/progo/pika/journal.py
>     #!/usr/bin/env python3

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?

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

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

    % j() { print -l :${^*} }
    % j Test. ABC this is a test.
    :Test.
    :ABC
    :this
    :is
    :a
    :test.
    % alias -g ABC='#'
    % j Test. ABC this is a test.
    :Test.
    %

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.

-Phil


  parent reply	other threads:[~2017-08-23 19:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 17:22 Mikael Puhakka
2017-08-22 18:40 ` Eitan Adler
2017-08-22 19:04   ` Daniel Shahaf
2017-08-22 19:19     ` Eitan Adler
2017-08-22 19:04   ` Mikael Puhakka
2017-08-23 19:17 ` Phil Pennock [this message]
2017-08-24  6:05   ` Mikael Puhakka
2017-08-24  8:48     ` Daniel Shahaf
2017-08-24  9:07       ` Mikael Puhakka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170823191739.GA35723@tower.spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=mr.progo@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).