On Sat, Mar 23, 2013 at 11:57 AM, Jonathan Callen <[email protected]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> On 03/23/2013 01:44 PM, Alec Warner wrote:
>> On Sat, Mar 23, 2013 at 9:26 AM, Michał Górny <[email protected]>
>> wrote:
>>> +                       # Close the lock file when we are done
>>> with it. +                       # Prevents deadlock if we aren't
>>> in a subshell. +                       eval "exec ${lock_fd}>&-"
>>
>> Not following this bit.
>>
>> The bash manpage says N>&DIGIT- redirects fd DIGIT to fd N. N may
>> be unspecified and defaults to 1.
>>
>> It doesn't say what happens if DIGIT is unspecified. Nor does it
>> say it closes any file descriptors.
>>
>
> The relevant section of bash(1) is reproduced below:
>
>    Duplicating File Descriptors
>        The redirection operator
>
>               [n]<&word
>
>        is used to duplicate input file descriptors.  If word expands to
>        one or more digits, the file descriptor denoted by n is made to
>        be a copy of that file descriptor.  If the digits in word do not
>        specify a file descriptor open for input, a redirection error
>        occurs.  If word evaluates to -, file descriptor n is closed.
>        If n is not specified, the standard input (file descriptor 0) is
>        used.
>
>        The operator
>
>               [n]>&word
>
>        is used similarly to duplicate output file descriptors.  If n is
>        not specified, the standard output (file descriptor 1) is used.
>        If the digits in word do not specify a file descriptor open for
>        output, a redirection error occurs.  As a special case, if n is
>        omitted, and word does not expand to one or more digits, the
>        standard output and standard error are redirected as described
>        previously.
>
> While the outcome of n>&- is not specified directly in the man page,
> it is treated exactly as n<&- is.

Ahh, I was reading:

   Moving File Descriptors
       The redirection operator

              [n]<&digit-

       moves the file descriptor digit to file descriptor n, or the
standard input (file descriptor 0) if n is not specified.  digit is
closed
       after being duplicated to n.

       Similarly, the redirection operator

              [n]>&digit-

       moves the file descriptor digit to file descriptor n, or the
standard output (file descriptor 1) if n is not specified.

I see where i went wrong now ;)

>
> - --
> Jonathan Callen
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.19 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCgAGBQJRTfsWAAoJELHSF2kinlg4MO0P+wTQovWzYdfSgUP8H4WFmO1y
> fpERqd1ZIoPle5Gl5+IUOWIHoMqkjS3mIAYUKF9cYwkufHRjbIs9l6NFGZg4wbRj
> baCW6dRTbnbaM/YSiHLlstb4I5fcSwldwhtJrMuO9O6qLq2IFupJYkaSLnYJMs6C
> HspU9W+bw4Vuvlk2wnhjGDGUj06ZIifQEOE6NYUVqF4GQaZlZpCsgA5BADPQL8zL
> RAb90dJuRIuPPwgzuFka1+h0z4Sg5xxSlV7FS4c+r+HzrZCHHIHSyi9lOpOPB/8M
> P+ZzJyDD3weW5AnAIuDjhJ3Rt0wI/2oYRRoVmC6hZ1CNSZuSjUCdWi6jvIvg99cR
> TscJ0dKBl7bMcrrIILcXYgHtyKC/QRZWp6r0JxqOwX4L7FbPhF3qbtano+TxoCSr
> X7hfCuRab1FEPE+jXeprH0c+N31SHrVBxfkJDG39MVx8hdJqXYzKCXah5/6lMJ63
> Td2lc7Y3UBuXpxvQBoBCWTEV3vmKBrNX6v5Bu9TTLmrhfkcMsjCMX6TdU54tUoEU
> YE37njpI4Thsl24/LPQtzkR8v9fVyYqVvvXylSq5HcM48VlqlhcI/EP0SRo9eUXu
> CFRkwb7u5nX4YOdUMj+L0P59/N7Zobdfs/dCvGB4PDeJTqzFJowxVhm7Dh1Uxf6l
> a1CBWFm9+S7kUPDTfwV6
> =tFvf
> -----END PGP SIGNATURE-----

Reply via email to