Actions
Bug #14212
closedar cra and crb don't work
Start date:
Due date:
% Done:
100%
Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:
Description
While writing a test suite for ar as part of trying to make #14105 actually work. I noticed that a basic test that should work according to the manual page didn't work on unmodified bits:
$ ar cr t.a ar_test0.o $ ar cra ar_test0.o t.a ar_test1.o ar: archive t.a not found $ ls t.a t.a
The problem here is the if statement logic that follows:
145 if ((fd == -1) && 146 (cmd_info->opt_flgs & 147 (d_FLAG | m_FLAG | p_FLAG | t_FLAG | x_FLAG)) || 148 ((cmd_info->opt_flgs & r_FLAG) && 149 (cmd_info->opt_flgs & (a_FLAG | b_FLAG)))) { 150 (void) fprintf(stderr, MSG_INTL(MSG_NOT_FOUND_AR), 151 cmd_info->arnam); 152 exit(1); 153 }
If you look at all the parenthesis games, if turns into if ((bad fd && set of flags) || (-r && (-a || -b)). This means that any use of -r and -a and -b would fail. Instead this should have been such that we only entered this case if we had a bad fd. Basically -r is allowed to have a file that doesn't exist, but only if neither -a or -b is passed which suggests updating an existing archive.
Updated by Robert Mustacchi almost 2 years ago
Updated by Electric Monk almost 2 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit fb25420ba8dbfa4c292d42c87555eee97a474854
commit fb25420ba8dbfa4c292d42c87555eee97a474854 Author: Robert Mustacchi <rm@fingolfin.org> Date: 2021-11-11T19:19:33.000Z 14105 ar -s could work on its own 14213 Want basic ar test suite 14212 ar cra and crb don't work 14214 ar usage message needs updating for -q Reviewed by: Rich Lowe <richlowe@richlowe.net> Reviewed by: Patrick Mooney <pmooney@pfmooney.com> Reviewed by: Andy Fiddaman <andy@omnios.org> Approved by: Dan McDonald <danmcd@joyent.com>
Actions