huf [he/him]

  • 0 Posts
  • 75 Comments
Joined 3 years ago
cake
Cake day: November 11th, 2021

help-circle




  • when you create the alias, the shell substitutes the $1 (to nothing, probably) since your alias is in "" (double quotes).
    now, if you swap the single and double quotes, then the substitution still happens, but at invocation time instead of at definition time.
    you actually want perl to deal with this $1, so neither is good.

    you have three options:

    • write a function instead, as has been suggested
    • use $'' quoting, which lets you put ’ (single quote) inside ’ (single quote) without going mad: alias cica=$'foo \'$bar\' baz'
    • go insane and do this: alias cica='foo '\''$bar'\'' baz' (this is the old way, without bash’s $'')















  • i have bad news: bash is already a massively improved/extended ksh clone. ksh was a massively improved/extended sh clone. sh got a ton of improvements early on.

    this is about as good as you can get without breaking compatibility completely (bash already breaks compatibility with posix sh in some ways).

    anyway, once you’ve figured out the hermetic incantations required to work with filenames with whitespace in them, it’ll be time to write scripts that can handle filenames with newlines in them :D