From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16635 invoked by alias); 31 Jan 2016 20:36:57 -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: 37855 Received: (qmail 24331 invoked from network); 31 Jan 2016 20:36:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=yWy9zVfaB+kVpwG/C8wnaEnSqBxobPSCA9ez4jy9pnQ=; b=z1d/AgL5yNhJ0faxk1FbEDDAEq9g20p1iukarUnyNK0W8pxlGvZxIIckvqtDMZiSeJ oFApmSGMRab16yGaxCJksEVVFmt6w8TcScDQhSzY6DhudZZdmQPv199ExDfmPJoWX/0x UXrOf6qrNm/jrVvSFWVqIgBVBzW6juPd8t2m2pbfyPOkJD/vTVNYQt1pSovrL9yBcRK3 E3b0OLmACMM6EgnogFTKA6f4wrJcWdMnojfY9NI4pvqfB4dB1eXsdQdrrPpt0WZpPE9V P4zyKOGKX2H2+/aNJN+5Nas/rRIYW/5t80uo9Xht3Eb2JJ+jA7Vlx46aIkio6FT6Nz/x 0m9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=yWy9zVfaB+kVpwG/C8wnaEnSqBxobPSCA9ez4jy9pnQ=; b=KTUEXIvHFq+tNK7ayaCVxqwaCNXe3uRg3S12iRSYFiYRwFgbBRtkjs0DH6wcTmTkGD 7TR2Yt9/Z3wRIN9+oqXGTtUp0Q3itOgGaOVyFDx8et1yXfOq3TQUVFiHI7sCZU1IBWOJ dmnnZnBA1kUjzljltCWd9a3k7FyREShvjRY5DRxWldENJa79OOQ/kVec6aeKfzRnrrvh VgTGDm5PrU/KFZJ0Vo41BcaNoTsKo5yCfSXO2N58mL5vudvvyRN815A0JautGU6m73iU cPCaRKRVbfFYCtbHwIw2pNK2C0+QsfnjUuYAlzYMNcbql+4UhvjXxRLpUqopfAmotElq WBWA== X-Gm-Message-State: AG10YOShrrTa2M/2VmIfgvYbJE7YbMKlUA3ti5KkhviTky95YnnWe/0X/qPDMTzyBh5qQw== X-Received: by 10.66.55.73 with SMTP id q9mr32795492pap.44.1454272614189; Sun, 31 Jan 2016 12:36:54 -0800 (PST) From: Bart Schaefer Message-Id: <160131123745.ZM12069@torch.brasslantern.com> Date: Sun, 31 Jan 2016 12:37:45 -0800 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Re: emulate -L sh impact on $0, $argv" (Jan 31, 8:13pm) References: <7850171454263927@web30j.yandex.ru> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: emulate -L sh impact on $0, $argv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 31, 8:13pm, Sebastian Gniazdowski wrote: } } In sh argv[0] is the same as argv[1]? Because again, you say I } shouldn't be able to use argv[0] without KSH_ARRAYS, but in the } examples, I do This is a side-effect KSH_ARRAYS combined with the behavior of $argv / $* / $@ when in the "source" command. Doc of "." command: If any arguments ARG are given, they become the positional parameters; the old positional parameters are restored when the FILE is done executing. What's left unsaid there is that if NO arguments are given, then the positional parameters REMAIN THOSE OF THE CALLING CONTEXT. So argv[0] in your example is not test_file.sh's $0, it's the "source" FUNCTION's $argv[1]. If you change your example to: echo 'echo 0 is $0, argv0 is ${argv[0]}, argv1 is ${argv[1]}' > test_file.sh; source ./test_file.sh ARGUMENT Then the zsh case source() { emulate -L zsh; builtin source "$@"; } will give 0 is ./test_file.sh, argv0 is , argv1 is ARGUMENT whereas the sh case source() { emulate -L sh; builtin source "$@"; } yields 0 is source, argv0 is ARGUMENT, argv1 is With KSH_ARRAYS set, $argv[0] == $1, $argv[1] == $2, etc.