aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-02-22 12:18:39 +0000
committerRon Yorston <rmy@pobox.com>2018-02-22 12:18:39 +0000
commitf46f3503fca50bfb397ed32d805158099a416f64 (patch)
tree6bc8fad0fc3bdd2ff27880bd7747c7d70e477a74
parent967510df361e0af44d7ca492ae2374674a535023 (diff)
downloadbusybox-w32-f46f3503fca50bfb397ed32d805158099a416f64.tar.gz
busybox-w32-f46f3503fca50bfb397ed32d805158099a416f64.tar.bz2
busybox-w32-f46f3503fca50bfb397ed32d805158099a416f64.zip
ash: tidy up /dev/null redirection
Remove some duplicated code and raise an error for unsupported devices.
-rw-r--r--shell/ash.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 59c1d2272..4c9c76b8c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5701,22 +5701,17 @@ openredirect(union node *redir)
5701 /* Support for /dev/null */ 5701 /* Support for /dev/null */
5702 switch (redir->nfile.type) { 5702 switch (redir->nfile.type) {
5703 case NFROM: 5703 case NFROM:
5704 if (!strcmp(fname, "/dev/null"))
5705 return open("nul",O_RDWR);
5706 if (!strncmp(fname, "/dev/", 5)) {
5707 ash_msg("Unhandled device %s\n", fname);
5708 return -1;
5709 }
5710 break;
5711
5712 case NFROMTO: 5704 case NFROMTO:
5713 case NTO: 5705 case NTO:
5706#if BASH_REDIR_OUTPUT
5707 case NTO2:
5708#endif
5714 case NCLOBBER: 5709 case NCLOBBER:
5715 case NAPPEND: 5710 case NAPPEND:
5716 if (!strcmp(fname, "/dev/null"))
5717 return open("nul",O_RDWR);
5718 if (!strncmp(fname, "/dev/", 5)) { 5711 if (!strncmp(fname, "/dev/", 5)) {
5719 ash_msg("Unhandled device %s\n", fname); 5712 if (!strcmp(fname+5, "null"))
5713 return open(fname,O_RDWR);
5714 ash_msg_and_raise_error("Unhandled device %s\n", fname);
5720 return -1; 5715 return -1;
5721 } 5716 }
5722 break; 5717 break;