git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Suppress some bash redirection error messages

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Aug 26, 2008, 17:52 UTC
Message-ID
<48B442F9.1090801@ramsay1.demon.co.uk>

In particular, when testing if the filesystem allows tabs in filenames, bash issues an error something like:

./t4016-diff-quote.sh: pathname	with HT: No such file or directory

which is caused by the failure of the (stdout) redirection, since the file cannot be created. In order to suppress the error message, you must redirect stderr to /dev/null, *before* the stdout redirection on the command-line.

Also, remove a redundant filesystem check from the begining of the t3902-quoted.sh test and standardise the "test skipped" message to 'say' on exit.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 t/t3300-funny-names.sh |    2 +-
 t/t3902-quoted.sh      |    8 +-------
 t/t4016-diff-quote.sh  |    4 ++--
 3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 0574ef1..db46d53 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -21,7 +21,7 @@ cat >"$p0" <<\EOF
 3. A quick brown fox jumps over the lazy cat, oops dog.
 EOF
 
-cat >"$p1" "$p0"
+cat 2>/dev/null >"$p1" "$p0"
 echo 'Foo Bar Baz' >"$p2"
 
 test -f "$p1" && cmp "$p0" "$p1" || {
diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh
index fe4fb51..5868052 100755
--- a/t/t3902-quoted.sh
+++ b/t/t3902-quoted.sh
@@ -7,12 +7,6 @@ test_description='quoted output'
 
 . ./test-lib.sh
 
-P1='pathname	with HT'
-: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || {
-	echo >&2 'Filesystem does not support HT in names'
-	test_done
-}
-
 FN='濱野'
 GN='純'
 HT='	'
@@ -20,7 +14,7 @@ LF='
 '
 DQ='"'
 
-echo foo > "Name and an${HT}HT"
+echo foo 2>/dev/null > "Name and an${HT}HT"
 test -f "Name and an${HT}HT" || {
 	# since FAT/NTFS does not allow tabs in filenames, skip this test
 	say 'Your filesystem does not allow tabs in filenames, test skipped.'
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
index f07035a..55eb5f8 100755
--- a/t/t4016-diff-quote.sh
+++ b/t/t4016-diff-quote.sh
@@ -13,8 +13,8 @@ P1='pathname	with HT'
 P2='pathname with SP'
 P3='pathname
 with LF'
-: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || {
-	echo >&2 'Filesystem does not support tabs in names'
+: 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || {
+	say 'Your filesystem does not allow tabs in filenames, test skipped.'
 	test_done
 }
 
-- 
1.6.0
Message 1 of 1 in “Suppress some bash redirection error messages”
  1. Suppress some bash redirection error messagesRamsay Jones, Aug 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.