X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Ffish.c;h=f5d538d12c11b055b0dce630cc1342a61b9abc23;hp=4042bbcf056cd61d70cd84182912bbe86f2a9197;hb=1a5755dbbff0fa4d87984cb7d67cb8239fd71a84;hpb=a86aa7d152ed996170714a3a4516eab58bf8b59d diff --git a/fish/fish.c b/fish/fish.c index 4042bbc..f5d538d 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -514,6 +514,7 @@ script (int prompt) char *argv[64]; int i, len; int global_exit_on_error = !prompt; + int tilde_candidate; if (prompt) printf (_("\n" @@ -587,6 +588,8 @@ script (int prompt) /* Get the parameters. */ while (*p && i < sizeof argv / sizeof argv[0]) { + tilde_candidate = 0; + /* Parameters which start with quotes or pipes are treated * specially. Bare parameters are delimited by whitespace. */ @@ -647,6 +650,11 @@ script (int prompt) *(pend-1) = '\0'; */ } else if (*p != ' ' && *p != '\t') { + /* If the first character is a ~ then note that this parameter + * is a candidate for ~username expansion. NB this does not + * apply to quoted parameters. + */ + tilde_candidate = *p == '~'; len = strcspn (p, " \t"); if (p[len]) { p[len] = '\0'; @@ -659,7 +667,11 @@ script (int prompt) abort (); } - argv[i++] = p; + if (!tilde_candidate) + argv[i] = p; + else + argv[i] = try_tilde_expansion (p); + i++; p = pend; if (*p)