Using file descriptor 4 in bash scripts - Help

This is a discussion on Using file descriptor 4 in bash scripts - Help ; May I safely use file descriptor 4 in a bash script?...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Using file descriptor 4 in bash scripts

  1. Using file descriptor 4 in bash scripts

    May I safely use file descriptor 4 in a bash script?

  2. Re: Using file descriptor 4 in bash scripts

    "Angel Tsankov" writes:

    >May I safely use file descriptor 4 in a bash script?


    For what?


  3. Re: Using file descriptor 4 in bash scripts

    Angel Tsankov wrote:
    > May I safely use file descriptor 4 in a bash script?


    What exactly is it file descriptor 4 pointing to?

    0 - stdin
    1 - stdout
    2 - stderr

    the remainer are usually for interfaces and devices (correct me if I am
    wrong here)

  4. Re: Using file descriptor 4 in bash scripts

    On 2006-10-17, Angel Tsankov wrote:
    > May I safely use file descriptor 4 in a bash script?


    Yes; the three descriptors in normal use are 0 (stdin), 1 (stdout),
    and 2 (stderr).

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  5. Re: Using file descriptor 4 in bash scripts

    >> May I safely use file descriptor 4 in a bash script?
    >
    > Yes; the three descriptors in normal use are 0 (stdin), 1
    > (stdout),
    > and 2 (stderr).


    Does this mean that fd 4 (or fd 3) won't be used by bash and is
    available to bash scripts?


  6. Re: Using file descriptor 4 in bash scripts

    On 2006-10-17, Angel Tsankov wrote:
    >>> May I safely use file descriptor 4 in a bash script?

    >>
    >> Yes; the three descriptors in normal use are 0 (stdin), 1
    >> (stdout),
    >> and 2 (stderr).

    >
    > Does this mean that fd 4 (or fd 3) won't be used by bash and is
    > available to bash scripts?


    That is correct.

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

  7. Re: Using file descriptor 4 in bash scripts

    >>>> May I safely use file descriptor 4 in a bash script?
    >>>
    >>> Yes; the three descriptors in normal use are 0 (stdin), 1
    >>> (stdout),
    >>> and 2 (stderr).

    >>
    >> Does this mean that fd 4 (or fd 3) won't be used by bash and
    >> is
    >> available to bash scripts?

    >
    > That is correct.


    This is fine. Is it documented anywhere?


  8. Re: Using file descriptor 4 in bash scripts

    On 2006-10-17, Angel Tsankov wrote:
    >>>>> May I safely use file descriptor 4 in a bash script?
    >>>>
    >>>> Yes; the three descriptors in normal use are 0 (stdin), 1
    >>>> (stdout),
    >>>> and 2 (stderr).
    >>>
    >>> Does this mean that fd 4 (or fd 3) won't be used by bash and
    >>> is
    >>> available to bash scripts?

    >>
    >> That is correct.

    >
    > This is fine. Is it documented anywhere?


    You can use any descriptor, even 0, 1, and 2. See the bash man page
    for more information. See also the POSIX spec:
    .

    --
    Chris F.A. Johnson, author |
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence

+ Reply to Thread