1 |
On Sat, Mar 23, 2013 at 11:57 AM, Jonathan Callen <abcd@g.o> wrote: |
2 |
> -----BEGIN PGP SIGNED MESSAGE----- |
3 |
> Hash: SHA512 |
4 |
> |
5 |
> On 03/23/2013 01:44 PM, Alec Warner wrote: |
6 |
>> On Sat, Mar 23, 2013 at 9:26 AM, Michał Górny <mgorny@g.o> |
7 |
>> wrote: |
8 |
>>> + # Close the lock file when we are done |
9 |
>>> with it. + # Prevents deadlock if we aren't |
10 |
>>> in a subshell. + eval "exec ${lock_fd}>&-" |
11 |
>> |
12 |
>> Not following this bit. |
13 |
>> |
14 |
>> The bash manpage says N>&DIGIT- redirects fd DIGIT to fd N. N may |
15 |
>> be unspecified and defaults to 1. |
16 |
>> |
17 |
>> It doesn't say what happens if DIGIT is unspecified. Nor does it |
18 |
>> say it closes any file descriptors. |
19 |
>> |
20 |
> |
21 |
> The relevant section of bash(1) is reproduced below: |
22 |
> |
23 |
> Duplicating File Descriptors |
24 |
> The redirection operator |
25 |
> |
26 |
> [n]<&word |
27 |
> |
28 |
> is used to duplicate input file descriptors. If word expands to |
29 |
> one or more digits, the file descriptor denoted by n is made to |
30 |
> be a copy of that file descriptor. If the digits in word do not |
31 |
> specify a file descriptor open for input, a redirection error |
32 |
> occurs. If word evaluates to -, file descriptor n is closed. |
33 |
> If n is not specified, the standard input (file descriptor 0) is |
34 |
> used. |
35 |
> |
36 |
> The operator |
37 |
> |
38 |
> [n]>&word |
39 |
> |
40 |
> is used similarly to duplicate output file descriptors. If n is |
41 |
> not specified, the standard output (file descriptor 1) is used. |
42 |
> If the digits in word do not specify a file descriptor open for |
43 |
> output, a redirection error occurs. As a special case, if n is |
44 |
> omitted, and word does not expand to one or more digits, the |
45 |
> standard output and standard error are redirected as described |
46 |
> previously. |
47 |
> |
48 |
> While the outcome of n>&- is not specified directly in the man page, |
49 |
> it is treated exactly as n<&- is. |
50 |
|
51 |
Ahh, I was reading: |
52 |
|
53 |
Moving File Descriptors |
54 |
The redirection operator |
55 |
|
56 |
[n]<&digit- |
57 |
|
58 |
moves the file descriptor digit to file descriptor n, or the |
59 |
standard input (file descriptor 0) if n is not specified. digit is |
60 |
closed |
61 |
after being duplicated to n. |
62 |
|
63 |
Similarly, the redirection operator |
64 |
|
65 |
[n]>&digit- |
66 |
|
67 |
moves the file descriptor digit to file descriptor n, or the |
68 |
standard output (file descriptor 1) if n is not specified. |
69 |
|
70 |
I see where i went wrong now ;) |
71 |
|
72 |
> |
73 |
> - -- |
74 |
> Jonathan Callen |
75 |
> -----BEGIN PGP SIGNATURE----- |
76 |
> Version: GnuPG v2.0.19 (GNU/Linux) |
77 |
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ |
78 |
> |
79 |
> iQIcBAEBCgAGBQJRTfsWAAoJELHSF2kinlg4MO0P+wTQovWzYdfSgUP8H4WFmO1y |
80 |
> fpERqd1ZIoPle5Gl5+IUOWIHoMqkjS3mIAYUKF9cYwkufHRjbIs9l6NFGZg4wbRj |
81 |
> baCW6dRTbnbaM/YSiHLlstb4I5fcSwldwhtJrMuO9O6qLq2IFupJYkaSLnYJMs6C |
82 |
> HspU9W+bw4Vuvlk2wnhjGDGUj06ZIifQEOE6NYUVqF4GQaZlZpCsgA5BADPQL8zL |
83 |
> RAb90dJuRIuPPwgzuFka1+h0z4Sg5xxSlV7FS4c+r+HzrZCHHIHSyi9lOpOPB/8M |
84 |
> P+ZzJyDD3weW5AnAIuDjhJ3Rt0wI/2oYRRoVmC6hZ1CNSZuSjUCdWi6jvIvg99cR |
85 |
> TscJ0dKBl7bMcrrIILcXYgHtyKC/QRZWp6r0JxqOwX4L7FbPhF3qbtano+TxoCSr |
86 |
> X7hfCuRab1FEPE+jXeprH0c+N31SHrVBxfkJDG39MVx8hdJqXYzKCXah5/6lMJ63 |
87 |
> Td2lc7Y3UBuXpxvQBoBCWTEV3vmKBrNX6v5Bu9TTLmrhfkcMsjCMX6TdU54tUoEU |
88 |
> YE37njpI4Thsl24/LPQtzkR8v9fVyYqVvvXylSq5HcM48VlqlhcI/EP0SRo9eUXu |
89 |
> CFRkwb7u5nX4YOdUMj+L0P59/N7Zobdfs/dCvGB4PDeJTqzFJowxVhm7Dh1Uxf6l |
90 |
> a1CBWFm9+S7kUPDTfwV6 |
91 |
> =tFvf |
92 |
> -----END PGP SIGNATURE----- |