qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: mreitz@redhat.com, kwolf@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: convert `pwd` and $(pwd) to $PWD
Date: Tue, 23 Oct 2018 09:21:55 +0100	[thread overview]
Message-ID: <af86e5b9-6af6-0425-326f-7e1e8372883e@redhat.com> (raw)
In-Reply-To: <20181022134807.27918-1-maozhongyi@cmss.chinamobile.com>

On 10/22/18 2:48 PM, Mao Zhongyi wrote:

The subject line says "what", but the commit body should say "why".  My 
suggestion:

POSIX requires $PWD to be reliable, and we expect all shells used by 
qemu scripts to be relatively close to POSIX.  Thus, it is smarter to 
avoid forking the pwd executable for something that is already available 
in the environment.



If it was done mechanically, it may also help to capture the command you 
used to drive the change (sed or otherwise), to make it easier for 
someone backporting this patch to rerun the same steps to regenerate the 
patch for a different set of files on the backport.

> Suggested-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
> ---

> +++ b/tests/qemu-iotests/001
> @@ -24,7 +24,7 @@ owner=hch@lst.de
>   seq=`basename $0`
>   echo "QA output created by $seq"
>   
> -here=`pwd`
> +here=$PWD

As this is a mechanical search-and-replace, this is fine.  However,
  git grep '\$here' tests/qemu-iotests
has 0 hits, which means we are setting a variable that has no use.  A 
good followup patch would be to delete all of the 'here=...' lines as 
dead code. Or even do that first, and then this patch second, for less 
churn.

> +++ b/tests/qemu-iotests/check
> @@ -80,17 +80,17 @@ _full_imgfmt_details()
>   
>   _full_platform_details()
>   {
> -    os=`uname -s`
> -    host=`hostname -s`
> -    kernel=`uname -r`
> -    platform=`uname -m`
> +    os=$(uname -s)
> +    host=$(hostname -s)
> +    kernel=$(uname -r)
> +    platform=$(uname -m)
>       echo "$os/$platform $host $kernel"

These changes are unrelated to the commit subject. Please split them 
into a separate commit...

>   }
>   
>   # $1 = prog to look for
>   set_prog_path()
>   {
> -    p=`command -v $1 2> /dev/null`
> +    p=$(command -v $1 2> /dev/null)
>       if [ -n "$p" -a -x "$p" ]; then
>           type -p "$p"
>       else
> @@ -99,7 +99,7 @@ set_prog_path()
>   }
>   
>   if [ -z "$TEST_DIR" ]; then
> -        TEST_DIR=`pwd`/scratch
> +        TEST_DIR=$PWD/scratch
>   fi

...This hunk is okay, but the rest of the file is not.


> +++ b/tests/qemu-iotests/common.config
> @@ -21,11 +21,11 @@ export LANG=C
>   
>   PATH=".:$PATH"
>   
> -HOSTOS=`uname -s`
> -arch=`uname -m`
> +HOSTOS=$(uname -s)
> +arch=$(uname -m)

Another file with too many hunks.

Looking forward to v2.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-10-23 21:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 13:48 [Qemu-devel] [PATCH] qemu-iotests: convert `pwd` and $(pwd) to $PWD Mao Zhongyi
2018-10-23  8:21 ` Eric Blake [this message]
2018-10-24  9:57   ` maozy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af86e5b9-6af6-0425-326f-7e1e8372883e@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=maozhongyi@cmss.chinamobile.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).