From: Cyril Hrubis <chrubis@suse.cz>
To: Jiri Jaburek <jjaburek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] testcases/lib/test.sh: added tst_timeout()
Date: Thu, 4 Dec 2014 12:23:11 +0100 [thread overview]
Message-ID: <20141204112311.GC15326@rei.suse.de> (raw)
In-Reply-To: <54803C62.30803@redhat.com>
Hi!
> > This is bashism. The portable way to do this seems to be do
> > tr -d [:digit:] on the string and checking if result is empty or use
> > grep.
>
> Indeed, 'tr' may be used in this case, but an (AFAIK) portable
> replacement for =~ is expr(1):
I do not care much about the way it's implemented. All we need is that
the code runs fine at least with bash, dash and bussybox.
> if ! expr "$timeout" : '.*[0-9]\+$' >/dev/null; then
>
> although, as you can see, there are several limitations:
>
> - IIRC the busybox version doesn't support '+ TOKEN' syntax, so we
> rely on ie. $timeout != "match"
> - different implementations may have different syntax, although the
> `:' notation is AFAIK the oldest
> - regexp matching is always done from the beginning, so there's `^'
> implied
> - path to /dev/null may be different on some systems (_PATH_DEVNULL),
> not sure if "/dev/null" is a POSIX requirement
We rely on /dev/null heavily in all parts of LTP. The goal is to be
portable across various Linux distributions, even embedded ones. We do
not care about rest of the UNIX world much (the exception is the Open
Posix Testsuite which should be written to the POSIX standard).
Ahd the whole problem reminds me an old saying:
"I'ts easier to implement portable shell than a porable shell code."
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-12-04 11:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 15:10 [LTP] [PATCH] testcases/lib/test.sh: added tst_timeout() Matus Marhefka
2014-12-02 12:38 ` Cyril Hrubis
[not found] ` <1961735972.12031389.1417528277602.JavaMail.zimbra@redhat.com>
2014-12-02 14:04 ` Cyril Hrubis
[not found] ` <54803C62.30803@redhat.com>
2014-12-04 11:23 ` Cyril Hrubis [this message]
2014-12-04 11:03 ` [LTP] [PATCH v2] " Matus Marhefka
2014-12-18 13:30 ` Cyril Hrubis
[not found] ` <1418987492-17553-1-git-send-email-mmarhefk@redhat.com>
2014-12-22 0:53 ` [LTP] [PATCH v3] " Wanlong Gao
2015-01-05 14:03 ` Cyril Hrubis
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=20141204112311.GC15326@rei.suse.de \
--to=chrubis@suse.cz \
--cc=jjaburek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
/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