From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21511 invoked by alias); 31 Jul 2013 08:14:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17901 Received: (qmail 4301 invoked from network); 31 Jul 2013 08:13:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at salk.edu does not designate permitted sender hosts) From: Chris Hiestand Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: globbing in a for loop may prematurely exit script when sourcing a zsh script Message-Id: <480F89D7-0191-4D79-B4D8-98E10E80436F@salk.edu> Date: Wed, 31 Jul 2013 01:13:47 -0700 To: zsh-users@zsh.org Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) X-Mailer: Apple Mail (2.1508) I am new to zsh and this is what I'm trying to do within = /etc/zsh/zshenv: > if [[ -d "/custom/zsh.d" ]]; then > for f in /custom/zsh.d/*.zsh; do > source $f > done 2> /dev/null > fi >=20 > #Do more stuff below... What happens in zsh 4.3.17 is that if /custom/zsh.d/*.zsh expands to no = files, zsh acts as if it hits err_return and "Do more stuff" does not get executed. Here is a test script test.zsh: > #!/usr/bin/zsh > setopt > unsetopt histignorealldups > unsetopt login > unsetopt monitor > unsetopt sharehistory > unsetopt zle > echo 'setopt again' > setopt >=20 >=20 > echo "Test 1" >=20 > ls /tmp/doesnotexist* >=20 > echo "Test 1 passed" >=20 > echo "Test 2" >=20 > if [ -d "/usr" ]; then > for f in /usr/*.zsh; do > echo $f > done > fi >=20 > echo "Test 2 passed" > user@host /tmp % ./test.zsh = = =20 > nohashdirs > setopt again > nohashdirs > Test 1 > ./test.zsh:15: no matches found: /tmp/doesnotexist* > Test 1 passed > Test 2 > ./test.zsh:22: no matches found: /usr/*.zsh > Test 2 passed >=20 > user@host /tmp % source test.zsh = = =20 > interactive > setopt again > interactive > Test 1 > test.zsh:15: no matches found: /tmp/doesnotexist* > Test 1 passed > Test 2 > test.zsh:22: no matches found: /usr/*.zsh > # Test 2 never finishes! It seems that this problem is limited to interactive shells. Is this a = bug or is this desirable behavior? Thanks!=