All of
 help / color / mirror / Atom feed
From: Petr Vorel <>
Subject: [LTP] [RFC PATCH 1/1] TCONF on basename error when setting TST_ID
Date: Wed,  2 May 2018 15:45:53 +0200	[thread overview]
Message-ID: <> (raw)

'basename $0' fails when loaded in command line with bash (at least)
as $0 is invalid ('-bash'):

    $ unset TST_ID; export TST_NO_DEFAULT_RUN=1; .
    -bash: No such file or directory
    basename: invalid option -- 'b'
    Try 'basename --help' for more information.

It's better to TCONF than be without TST_ID.

NOTE: Sourcing can be needed for network scripts: users
might want to set network variables with, which itself

Signed-off-by: Petr Vorel <>
 testcases/lib/ | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/lib/ b/testcases/lib/
index 8d49d34b6..39744d29e 100644
--- a/testcases/lib/
+++ b/testcases/lib/
@@ -377,7 +377,8 @@ tst_run()
 if [ -z "$TST_ID" ]; then
-	filename=$(basename $0)
+	filename=$(basename $0) || \
+		tst_brk TBROK "Failed to set TST_ID from \$0 ('$0'), fix it with setting TST_ID before sourcing"
 export TST_ID="$TST_ID"

             reply	other threads:[~2018-05-02 13:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 13:45 Petr Vorel [this message]
2018-05-02 14:45 ` [LTP] [RFC PATCH 1/1] TCONF on basename error when setting TST_ID Petr Vorel
2018-05-03  7:54   ` Li Wang
2018-06-01  9:48     ` Petr Vorel

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:

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

  git send-email \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.