I wonder if there's a better solution to this. BusyBox has bb_perror_msg() and like. Maybe using these API's are better?
On Mon, Jul 17, 2017 at 4:08 AM, Johannes Schindelin <johannes.schinde...@gmx.de> wrote: > GLIBC's printf() family supports the extension where the placeholder %m > is interpolated to strerror(errno). > > This is not portable. So don't use it. (It was only used in ash's source > code to begin with.) > > Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de> > --- > Published-As: > https://github.com/dscho/busybox-w32/releases/tag/busybox-glibc-ism-v1 > Fetch-It-Via: git fetch https://github.com/dscho/busybox-w32 > busybox-glibc-ism-v1 > shell/ash.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/shell/ash.c b/shell/ash.c > index b0c7dac54..e2ff15767 100644 > --- a/shell/ash.c > +++ b/shell/ash.c > @@ -3809,8 +3809,10 @@ freejob(struct job *jp) > static void > xtcsetpgrp(int fd, pid_t pgrp) > { > - if (tcsetpgrp(fd, pgrp)) > - ash_msg_and_raise_error("can't set tty process group (%m)"); > + if (tcsetpgrp(fd, pgrp)) { > + const char *err = strerror(errno); > + ash_msg_and_raise_error("can't set tty process group (%s)", > err); > + } > } > > /* > @@ -5343,7 +5345,7 @@ savefd(int from) > err = newfd < 0 ? errno : 0; > if (err != EBADF) { > if (err) > - ash_msg_and_raise_error("%d: %m", from); > + ash_msg_and_raise_error("%d: %s", from, > strerror(errno)); > close(from); > fcntl(newfd, F_SETFD, FD_CLOEXEC); > } > @@ -5358,7 +5360,7 @@ dup2_or_raise(int from, int to) > newfd = (from != to) ? dup2(from, to) : to; > if (newfd < 0) { > /* Happens when source fd is not open: try "echo >&99" */ > - ash_msg_and_raise_error("%d: %m", from); > + ash_msg_and_raise_error("%d: %s", from, strerror(errno)); > } > return newfd; > } > @@ -5489,7 +5491,7 @@ redirect(union node *redir, int flags) > /* "echo >&10" and 10 is a fd opened to a sh script? > */ > if (is_hidden_fd(sv, right_fd)) { > errno = EBADF; /* as if it is closed */ > - ash_msg_and_raise_error("%d: %m", right_fd); > + ash_msg_and_raise_error("%d: %s", right_fd, > strerror(errno)); > } > newfd = -1; > } else { > @@ -5523,7 +5525,7 @@ redirect(union node *redir, int flags) > if (newfd >= 0) > close(newfd); > errno = i; > - ash_msg_and_raise_error("%d: %m", fd); > + ash_msg_and_raise_error("%d: %s", fd, > strerror(errno)); > /* NOTREACHED */ > } > /* EBADF: it is not open - good, remember to > close it */ > > base-commit: 68e980545af6a8ffb2980f94a6edac4dd89940f3 > -- > 2.13.3.windows.1.13.gaf0c2223da0 > _______________________________________________ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox