Guest User

Untitled

a guest
Jan 22nd, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. # set -x # what I typed
  2. # echo 'love' # ...
  3. + echo love <--(1) the trace
  4. love # the output
  5.  
  6. # echo love? # note the input contains no quote whatsoever
  7. + echo 'love?' <--(2) note the trace contains quotes after returning word
  8. love? # i.e. failed to find any file
  9.  
  10. # echo 'love?' # note the input contains single quotes
  11. + echo 'love?' <--(3) traces like (2)
  12. love?
  13.  
  14. # touch loveu # we create a file that matches the love? pattern
  15. + touch loveu
  16.  
  17. # echo love? # of course now, the pattern matches the created file now
  18. + echo loveu <--(4) indeed it finds it and expands to name
  19. loveu # the name is echoed
  20.  
  21. # for i in love love? 'love?'; do echo $i; done
  22. + for i in love 'love?' ''''love?''''
  23. + echo love
  24. love
  25. + for i in love 'love?' ''''love?''''
  26. + echo 'love?'
  27. love?
  28. + for i in love 'love?' ''''love?''''
  29. + echo 'love?'
  30. love?
  31.  
  32. $ set -x
  33. $ echo foo;bar
  34. + echo 'foo;bar'
  35.  
  36. /* A function to print the words of a simple command when set -x is on. */
  37. void
  38. xtrace_print_word_list (list, xtflags)
  39. ...
  40. {
  41. ...
  42. for (w = list; w; w = w->next)
  43. {
  44. t = w->word->word;
  45. ...
  46. else if (sh_contains_shell_metas (t))
  47. {
  48. x = sh_single_quote (t);
  49. fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");
  50. free (x);
  51. }
  52.  
  53. /* Print the value cell of VAR, a shell variable. Do not print
  54. the name, nor leading/trailing newline. If QUOTE is non-zero,
  55. and the value contains shell metacharacters, quote the value
  56. in such a way that it can be read back in. */
  57. void
  58. print_var_value (var, quote)
  59. ...
  60. {
  61. ...
  62. else if (quote && sh_contains_shell_metas (value_cell (var)))
  63. {
  64. t = sh_single_quote (value_cell (var));
  65. printf ("%s", t);
  66. free (t);
  67. }
Add Comment
Please, Sign In to add comment