From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11197 invoked by alias); 23 Aug 2017 19:18:00 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41589 Received: (qmail 6352 invoked by uid 1010); 23 Aug 2017 19:18:00 -0000 X-Qmail-Scanner-Diagnostics: from mx.spodhuis.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(94.142.241.89):SA:0(-4.2/5.0):. Processed in 3.813524 secs); 23 Aug 2017 19:18:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: zsh-workers+phil.pennock@spodhuis.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201708; h=In-Reply-To:Content-Type:MIME-Version:References :Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+yOwyK7qjwskNLxxGgVPBGQRXe6vF3EObZzDW0HEqlY=; b=cGL/46gY1hox7h2kXjQV02Ayjt J9TijzMSE8hQXyKLbkWiIz+I4lqw7xW1kT4i0ssBdfpvB7XVu30R5HF13sBWhfUl7knZd+kFFMzFc GUjpNfSYEys0iVFRVNqsiVcQk8hkRiKJkfGNItmDHtrivBLikR7jFZeXQNMemvJiN/XN8GIw2Wb0L IyXywA84iUDdOhVgC54YabL7WLr6; Date: Wed, 23 Aug 2017 15:17:39 -0400 From: Phil Pennock To: Mikael Puhakka Cc: zsh-workers@zsh.org Subject: Re: Two different zsh sessions handle $* differently Message-ID: <20170823191739.GA35723@tower.spodhuis.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: OpenPGP: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc 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