Mercurial > hg > toybox
diff toys/other/pwdx.c @ 1150:ac4a0cde89c2 draft
Don't permute toys.optargs, cleanup code (xexec()) can free it.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 19 Dec 2013 21:38:12 -0600 |
parents | 75f5e63d79c3 |
children | 0752b2d58909 |
line wrap: on
line diff
--- a/toys/other/pwdx.c Thu Dec 19 15:14:33 2013 -0600 +++ b/toys/other/pwdx.c Thu Dec 19 21:38:12 2013 -0600 @@ -17,11 +17,13 @@ void pwdx_main(void) { - for (; *toys.optargs; toys.optargs++) { + char **optargs; + + for (optargs = toys.optargs; *optargs; optargs++) { char *path; int num_bytes; - path = xmsprintf("/proc/%s/cwd", *toys.optargs); + path = xmsprintf("/proc/%s/cwd", *optargs); num_bytes = readlink(path, toybuf, sizeof(toybuf)-1); free(path); @@ -32,6 +34,6 @@ path = toybuf; toybuf[num_bytes] = 0; } - xprintf("%s: %s\n", *toys.optargs, path); + xprintf("%s: %s\n", *optargs, path); } }