mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
(main): Open the output file with *read* access
only if we might need to read to satisfy a `seek=' request. From Matthias Urlichs.
This commit is contained in:
1 parent
64dec9fafb
commit
8f913cc64f
1 file changed
+3
-1
@@ -1121,7 +1121,9 @@ main (int argc, char **argv)
|
||||
|
||||
if (output_file != NULL)
|
||||
{
|
||||
int omode = O_RDWR | O_CREAT;
|
||||
/* Open the output file with *read* access only if we might
|
||||
need to read to satisfy a `seek=' request. */
|
||||
int omode = (seek_record ? O_RDWR : O_WRONLY) | O_CREAT;
|
||||
|
||||
if (seek_record == 0 && !(conversions_mask & C_NOTRUNC))
|
||||
omode |= O_TRUNC;
|
||||
|
||||
Reference in new issue
Block a user