From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22546 invoked by alias); 9 Sep 2017 13:10:50 -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: 22873 Received: (qmail 757 invoked by uid 1010); 9 Sep 2017 13:10:50 -0000 X-Qmail-Scanner-Diagnostics: from 195.159.176.226 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(195.159.176.226):SA:0(-0.9/5.0):. Processed in 6.249819 secs); 09 Sep 2017 13:10:50 -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=-0.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RDNS_NONE,T_SPF_HELO_TEMPERROR autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: gcszu-zsh-users@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-users@zsh.org To: zsh-users@zsh.org From: Emanuel Berg Subject: string overwrites string when echoed Date: Sat, 09 Sep 2017 14:55:23 +0200 Message-ID: <86o9qkqbes.fsf@zoho.com> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Mail-Copies-To: never Cancel-Lock: sha1:9OS+ocLl4o+5RlRx4wga3J6gG1g= Here is a problem that really puzzles me. I re-wrote the original DWIM function, that branched on $#, into two function to identify the issue. Now I know where the issue is - the commented lines - but not why it happens. Ideas? TIA. url-exists () { local url=$1 curl -s -I $url | head -n 1 | cut -d\ -f2,3,4 } alias url=url-exists urls-exist () { local -a urls urls=($@) local reply for u in $urls; do reply=$(url $u) echo "$u $reply" # works echo "$reply $u" # doesn't work, $u overwrites $reply done } alias urls=urls-exist -- underground experts united http://user.it.uu.se/~embe8573