mylsh

my own shell, based on brenns10's
git clone https://github.com/jennydoe/mylsh.git
Log | Files | Refs | Feed | README

commit 199843bfa7b7654cd95de863a6baa448432f8901
parent 2e2f11c0fac547c2259de537a5d015ef10067f79
Author: Jenny Doe <tng@soykaf.me>
Date:   Tue, 19 Mar 2019 19:57:23 +0100

fixed: added temporary variables since wcsrtombs has side-effects

Diffstat:
Mlsh.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lsh.c b/lsh.c @@ -87,13 +87,14 @@ lsh_execute(wchar_t * *words) * hint would be appreciated: mailto tng@soykaf.me */ size_t l = 2 + 2 * sizeof(char) * wcslen(words[1]); + char **v = &words[1]; char *t = malloc(l); if (t == NULL) { fprintf(stderr, "out of memory\n"); exit(1); } - wcsrtombs(&t[0], &words[1], l, NULL); + wcsrtombs(&t[0], v, l, NULL); syslog(LOG_DEBUG, "chdir to %s\n", t); if (chdir(t) == -1) @@ -111,13 +112,14 @@ lsh_execute(wchar_t * *words) } else { int l = 2 + 2 * sizeof(char) * wcslen(words[1]); + char **v = &words[1]; char *t = malloc(l); if (t == NULL) { fprintf(stderr, "out of memory\n"); exit(1); } - wcsrtombs(&t[0], &words[1], l, NULL); + wcsrtombs(&t[0], v, l, NULL); int code = atoi(t); free(t);