Project

General

Profile

Actions

Bug #14212

closed

ar cra and crb don't work

Added by Robert Mustacchi 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

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.

Actions #1

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1723
Actions #2

Updated by Robert Mustacchi 6 months ago

This was tested first with specific test suite additions under the guise of #14213. In addition, we had the broader testing of all of the OmniOS packages being built with this. See #14105 for more details there.

Actions #3

Updated by Electric Monk 6 months 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

Also available in: Atom PDF