From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6135 invoked by alias); 1 Jan 2016 18:45:21 -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: 37471 Received: (qmail 28804 invoked from network); 1 Jan 2016 18:45:20 -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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=doIarPLbDrgN9jpEnVLunhcU6X9REgMI030dwKVcXJc=; b=DMWpUaDkJWIuebmN8rjy/pLaJpOVfMHS9LODkEtWCFytpEJrKIFihJ8nTAnE0Q2Zmj YNpjQgARqeMuvyLa0oIx05n0jrRfRSkq6kWjtVX+ZYT/ScWT2KlxixcAorCr7X7fxB3w wb/D6prlc4DlvKE2I5GA1Ja8AlmHHuFAlsGYGOXkW58M4NefDlm8k+1Uvzr+DVWzIf6i lJOrdTmnQCuyYXu8sRHqO0Jj+MW0SNVlt2y7UvEDA8ZW8j6h6yl/1YNUoKb9Rb8mKGbX NwecvKiT9JJZ7N5+AAKbt3DbmyEel5cI3qlimFsfLrg1T41SPmPQsJubSnIrDFO9T9yX HHPg== X-Received: by 10.28.184.76 with SMTP id i73mr73884586wmf.43.1451673918492; Fri, 01 Jan 2016 10:45:18 -0800 (PST) Date: Fri, 1 Jan 2016 18:45:16 +0000 From: Stephane Chazelas To: "Starms, William Albert (MU-Student)" Cc: "zsh-workers@zsh.org" Subject: Re: Printf builtin missing v flag support Message-ID: <20160101184516.GB8456@chaz.gmail.com> Mail-Followup-To: "Starms, William Albert (MU-Student)" , "zsh-workers@zsh.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 2015-12-31 07:16:00 +0000, Starms, William Albert (MU-Student): > I had a script malfunctioning on me and printing “-v” to > stdout, and I found that it’s because zsh (version 5.2) > doesn’t seem to support the v flag that bash has. I did some > digging through GNU's bash source and it seems to have been > added somewhere between 3.0 and 3.1. According to the bash > documentation: > > printf: printf [-v var] format [arguments] [...] Yes, that's a bash-specific feature. See also ksh93 where: var=$(printf format arg) doesn't involve a fork nor pipe (but still trims the trailing newline characters) ksh93 tries to only fork to execute external commands. For builtins when used in command substitutions, ksh93 just adds their output to the substituted value without actually going through the whole actual printing through a pipe and reading at the other end. That avoids having to add a -v for every builtin command. $(...) still creates a subshell environment though. -- Stephane