Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # set -x # what I typed
- # echo 'love' # ...
- + echo love <--(1) the trace
- love # the output
- # echo love? # note the input contains no quote whatsoever
- + echo 'love?' <--(2) note the trace contains quotes after returning word
- love? # i.e. failed to find any file
- # echo 'love?' # note the input contains single quotes
- + echo 'love?' <--(3) traces like (2)
- love?
- # touch loveu # we create a file that matches the love? pattern
- + touch loveu
- # echo love? # of course now, the pattern matches the created file now
- + echo loveu <--(4) indeed it finds it and expands to name
- loveu # the name is echoed
- # for i in love love? 'love?'; do echo $i; done
- + for i in love 'love?' ''''love?''''
- + echo love
- love
- + for i in love 'love?' ''''love?''''
- + echo 'love?'
- love?
- + for i in love 'love?' ''''love?''''
- + echo 'love?'
- love?
- $ set -x
- $ echo foo;bar
- + echo 'foo;bar'
- /* A function to print the words of a simple command when set -x is on. */
- void
- xtrace_print_word_list (list, xtflags)
- ...
- {
- ...
- for (w = list; w; w = w->next)
- {
- t = w->word->word;
- ...
- else if (sh_contains_shell_metas (t))
- {
- x = sh_single_quote (t);
- fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");
- free (x);
- }
- /* Print the value cell of VAR, a shell variable. Do not print
- the name, nor leading/trailing newline. If QUOTE is non-zero,
- and the value contains shell metacharacters, quote the value
- in such a way that it can be read back in. */
- void
- print_var_value (var, quote)
- ...
- {
- ...
- else if (quote && sh_contains_shell_metas (value_cell (var)))
- {
- t = sh_single_quote (value_cell (var));
- printf ("%s", t);
- free (t);
- }
Add Comment
Please, Sign In to add comment