Login
You're viewing the fosstodon.org public feed.
  • Oct 21, 2026, 6:07 AM

    if you put spaces around an equal sign when assigning a variable it will break, because the lack of a space is how it distinguishes variable assignment from invoking a command. if you DON'T put spaces around a bracketed if condition it will break, because [ is actually secretly a command and doesn't get parsed specially.

    you can't have a null byte in the middle of a variable. also if you do VARIABLE="$(command)" and command outputs a newline, bash will silently replace the newline with a space, so if you try to capture a list of filenames with spaces in them from e.g. find and then pass that list to another command, you will be in for a nasty surprise. what you have to do instead is use a bash array. there is not special syntax for constructing one, so you have to start with an empty array and then read lines one by one from the command output and append them to the array with a while loop.

    it is 2026 and people genuinely do not see a problem with this.

    2/2

    💬 0🔄 0⭐ 0