Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change order of arguments to set-attr #30

Closed
fadden opened this issue Sep 5, 2024 · 1 comment
Closed

Change order of arguments to set-attr #30

fadden opened this issue Sep 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@fadden
Copy link
Owner

fadden commented Sep 5, 2024

The current definition of the set-attr command is:
set-attr [options] <ext-archive> <file-in-archive> [attrs...]

The optional attrs argument is a space-separated list of attributes, e.g. type=BIN aux=0x2000. If the attribute list is omitted, the command behaves like get-attr instead (there is no get-attr command). There are a couple of problems with this:

  • The pattern diverges from commands like UNIX chmod, which take a list of filenames.
  • The pattern diverges from other cp2 commands, like export [options] <ext-archive> <export-spec> [file-in-archive...], which put a "specification" between the ext-archive argument and the filename list.
  • Getting attributes with set-attr feels a little weird.

Furthermore, the current argument order prevents the command from allowing the user to mark a big pile of files read-only with a statement like cp2 set-attr mydisk.po locked file1 file2 file3.

Four changes should be made:

  1. The order of arguments should be changed, so that the attributes come before the filename.
  2. The attributes should be a comma-separated list, rather than space-separated. This is for convenience when setting multiple attributes.
  3. The command should take multiple filenames, with the usual wildcard support.
  4. The no-attribute form of the command no longer makes sense, so we need a get-attr command.

Switching from space-separated to comma-separated shouldn't cause problems. The only opportunity for commas to appear naturally is in the Mac creator/file type strings, but that should be rare, and those allow hex digits to be provided.

This should improve the function of the command, and allow the behavior requested in issue #27.

The command should only descend into subdirectories if --recurse is given on the command line. It's reasonable to change the attributes of a directory.

The get-attr command is fundamentally a single-file command. The argument order should be the same as the old set-attr, so that we can take an attribute name as an optional argument:
get-attr [options] <ext-archive> <file-in-archive> [attr]

The idea is that get-attr file dumps the full list of attributes as human-readable name/value pairs, while e.g. get-attr file type just prints the value in a machine-readable sort of way. This could be useful for shell scripts.

Sample of current output:

Attributes for 'Pics.3200/ROSE.3200':
  File Type   : PNT $c0
  Aux Type    : $8005
  HFS Type    : '␀␀␀␀' $00000000
  HFS Creator : '␀␀␀␀' $00000000
  Access      : $e3 [dnbwr]
  Create Date : 24-Sep-1991 01:12:00
  Mod Date    : 24-Sep-1991 01:12:00
  Comment     : (none)
@fadden fadden added the enhancement New feature or request label Sep 5, 2024
fadden added a commit that referenced this issue Sep 9, 2024
Multiple changes:
 - The order of arguments to set-attr has been changed, so that the
   attributes come before the filename.
 - set-attr now takes multiple filenames, and accepts wildcards and the
   --recurse argument.
 - The set-attr attribute changes are now provided in a comma-separated
   list, rather than space-separated.
 - Added new "get-attr" command.  This replaces the previous "show
   attributes if no edit args were specified" approach.

This was a bit awkward for MacZip archives.  set-attr is a read-
modify-write operation, but IArchive doesn't allow you to extract
file parts while a transaction is in progress.  So we need to
pre-flight all of the edits.

Documentation and tests have been updated.

Also, added a new line to the get-attr output that indicates whether
the entry is a plain file or a directory.  It also shows "dubious"
and "damaged" state.

(issue #30)
@fadden
Copy link
Owner Author

fadden commented Sep 9, 2024

@fadden fadden closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant