A Personalized Echo

Sort by

recency

|

141 Discussions

|

  • + 0 comments
    read name; echo "Welcome $name"
    
  • + 0 comments

    I know this is a beginner-level challenge, but I'm surprised the test cases are so kind. The echo command does not emit all its input completely literally—it will transform escaped characters, for example. And feeding the input through read and then double-quoted string can mangle things too.

    $ read name; echo "Welcome $name"
    \n\tChuckles\n\t
    Welcome ntChucklesnt
    
    $ printf 'Welcome %s\n' $(cat)
    \n\tChuckles\n\t
    Welcome \n\tChuckles\n\t
    
  • + 0 comments
    read name
    echo "Welcome $name"
    
  • + 0 comments

    read -p "Dane" name

    echo "Welcome $name"

  • + 0 comments

    This also works:

    CMD="$(echo "cmVhZCBuYW1lOyBlY2hvICJXZWxjb21lICRuYW1lIg==" | base64 -d)"; eval $CMD
    

    It's weird, I know.