diff --git a/edit.c b/edit.c index fb5b426..4b062a1 100644 --- a/edit.c +++ b/edit.c @@ -28,7 +28,7 @@ #ifndef MKSH_NO_CMDLINE_EDITING -__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.249 2012/08/24 20:57:44 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.250 2012/08/24 21:15:40 tg Exp $"); /* * in later versions we might use libtermcap for this, but since external @@ -379,7 +379,7 @@ x_file_glob(int *flagsp, char *toglob, char ***wordsp) /* probably a $FOO expansion */ *flagsp |= XCF_IS_NOSPACE; /* this always results in at most one match */ - nwords = DOKEEPQCHAR; + nwords = 0; } expand(yylval.cp, &w, nwords); XPput(w, NULL); @@ -812,24 +812,20 @@ glob_path(int flags, const char *pat, XPtrV *wp, const char *lpath) static int x_escape(const char *s, size_t len, int (*putbuf_func)(const char *, size_t)) { - char ch; size_t add = 0, wlen = len; const char *ifs = str_val(local("IFS", 0)); int rval = 0; - while (wlen - add > 0) { - ch = s[add]; - if (vstrchr("\"#$&'()*:;<=>?[\\`{|}", ch) || - ch == QCHAR || vstrchr(ifs, ch)) { + while (wlen - add > 0) + if (vstrchr("\"#$&'()*:;<=>?[\\`{|}", s[add]) || + vstrchr(ifs, s[add])) { if (putbuf_func(s, add) != 0) { rval = -1; break; } - putbuf_func(ch == '\n' ? "'" : "\\", 1); - if (ch == QCHAR) - ++add; + putbuf_func(s[add] == '\n' ? "'" : "\\", 1); putbuf_func(&s[add], 1); - if (ch == '\n') + if (s[add] == '\n') putbuf_func("'", 1); add++; @@ -838,7 +834,6 @@ x_escape(const char *s, size_t len, int (*putbuf_func)(const char *, size_t)) add = 0; } else ++add; - } if (wlen > 0 && rval == 0) rval = putbuf_func(s, wlen); @@ -2774,15 +2769,16 @@ do_complete( /* * do some tilde expansion; we know at this * point (by means of having nwords > 1) that - * the string looke like "~foo/bar" + * the string looks like "~foo/bar" and that + * the tilde resolves */ - char *cp, *dp; + char *cp; cp = ucstrchr(unescaped + 1, '/'); *cp++ = 0; - if ((dp = tilde(unescaped + 1))) { - /* got a match */ - } + cp = shf_smprintf("%s/%s", tilde(unescaped + 1), cp); + afree(unescaped, ATEMP); + unescaped = cp; } /* ... convert it from backslash-escaped via QCHAR-escaped... */ diff --git a/eval.c b/eval.c index 29396ca..119d2bd 100644 --- a/eval.c +++ b/eval.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.127 2012/08/24 20:57:45 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.128 2012/08/24 21:15:42 tg Exp $"); /* * string expansion @@ -1008,12 +1008,9 @@ expand(const char *cp, /* input word */ } break; } - else { + else /* undo temporary */ quote &= ~2; - if (f & DOKEEPQCHAR) - *dp++ = QCHAR; - } if (make_magic) { make_magic = false; diff --git a/sh.h b/sh.h index 5d197ac..90cd773 100644 --- a/sh.h +++ b/sh.h @@ -157,7 +157,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.582 2012/08/24 20:57:46 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.583 2012/08/24 21:15:42 tg Exp $"); #endif #define MKSH_VERSION "R40 2012/08/17" @@ -1343,7 +1343,6 @@ struct ioword { #define DOTEMP BIT(8) /* dito: in word part of ${..[%#=?]..} */ #define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */ #define DOMARKDIRS BIT(10) /* force markdirs behaviour */ -#define DOKEEPQCHAR BIT(11) /* internal use by globbing code */ /* * The arguments of [[ .. ]] expressions are kept in t->args[] and flags