From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12783 invoked by alias); 10 Sep 2017 18:24:00 -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: 22886 Received: (qmail 16272 invoked by uid 1010); 10 Sep 2017 18:24:00 -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 2.665362 secs); 10 Sep 2017 18:24: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=-0.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RDNS_NONE 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: Re: string overwrites string when echoed Date: Sun, 10 Sep 2017 20:23:08 +0200 Message-ID: <86o9qimn03.fsf@zoho.com> References: <86o9qkqbes.fsf@zoho.com> <170909100149.ZM8451@torch.brasslantern.com> <86shfumrzm.fsf@zoho.com> <20170910175943.77a8313a@ntlworld.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:qvu/LAboz01Rg1meFkYJ/Cyruxg= Peter Stephenson wrote: > Replacing $reply with ${reply%%$'\r'} would > do the trick. > > There may be something you can do with stty, > but that's a bit out of the scope of the > shell (or indeed sanity :-(). Ha! Yes, it works. Thank you! Feel free to elaborate on ${reply%%$'\r'}. What does it do? Remove the last char of the string if it matches the char given? I take it the $ is because of the special char single quotes. I get the same result with only one % by the way. Does this look good? url-exists () { local url=$1 curl -s -I $url | head -n 1 | cut -d\ -f2,3,4 } urls-exist () { local -a urls urls=($@) local pad_max=$(echo "404 Not Found" | wc -m) local reply for u in $urls; do reply=$(url-exists $u) echo ${(r:$pad_max:: :)reply%%$'\r'} $u done } alias url=urls-exist -- underground experts united http://user.it.uu.se/~embe8573