Tag | shell

  1. Colon Built-in in Bash

    I came across a weird line in a shell script:

    : ${parameter:=word}
    

    It is so weird that I don't even know how to search for further information. Fortunately, I found a post after searching bash colon. It is a built-in utility which simply exits with 0. In the other words …

    More

  2. Open and Close Files in Bash

    In a shell script, file descriptor 0 stands for stdin, file descriptor 1 stands for stdout, and file descriptor 2 stands for stderr. In addition, programmers can open, close, or duplicate file descriptors with the exec built-in command and the I/O redirection operator:

    Syntax Description
    exec $fd< "${filepath}" Open …

    More

  3. Bash Signal Handler and Traps

    I would like to launch ssh-agent and add my private key at the beginning of my shell script and stop it before leaving the shell script. How do I guarantee that ssh-agent will be shutted down properly? What will happen if the user press Ctrl-C or even kill the shell …

    More