[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: factor tests: ugly long file names

From: Jim Meyering
Subject: Re: factor tests: ugly long file names
Date: Sat, 27 Oct 2012 11:14:31 +0200

Stefano Lattarini wrote:
>>> You can save a fork by avoiding a call to basename:
>>>     t=${testname##*/}
>> Good point. I wasn't sure if that syntax is portable.
>> I know it from old dtksh days.
> It is portable to any decent POSIX shell.  And I think Coreutils assumes
> that one is available on the build system.  But then, to ensure such a
> shell is actually used, you'll have to invoke your script explicitly with
> the configure-determined $(SHELL) from the make recipe below (thank you
> Solaris for keeping an old non-POSIX shell as /bin/sh, sigh).
> Jim, can you confirm it's OK to assume that $(SHELL) points to a POSIX
> shell in the coreutils build system?

It's even better than that.
coreutils (via guarantees that the shell
used to invoke tests accepts $(...) syntax, so we don't
have to use the anachronistic `...`.

It appears that every shell meeting the above criteria also
supports ${var##X}, ${var#X}, ${var%%X}, etc. substitution,
since this use has been in a test since 2007:

    symlink_loop_msg=${readlink_msg#'readlink: p/1: '} explicitly requires ${var#X} support and a couple
other shell features when $(EXEEXT) is nonempty, but I doubt
you're building on mingw.

So, yes, it is safe to use that syntax in coreutils tests/ scripts.

Thanks for reviewing.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]