7z defaults to archiving files in current directory
A free file archiver for extremely high compression
Brought to you by:
ipavlov
7zip uses current directory if I uses "a" (add) command with no file names specified.
# add command without file names
7z a foo.7z
...(add files in current folder to foo.7z)
I think this is an unwanted behavior.
Because other archiver like Zip and Tar provides error when no file names specified.
# provides errors and not touch archive file
zip foo.zip
tar cf foo.tar
"rn" (rename) command acts more strange.
When I don't add file names for "rn" command, 7zip acts like "a" (add) command and adds files in current directory.
# rename command with no file rename list
7z rn foo.7z
...(add files in current folder to foo.7z)
I think these 7zip behavior is not expected for users.
Because other archiver like Zip and others doesn't add files when not specified any files.
See Debian's bug report for more info:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1091693
I'll fix the issue with rename command.
But I don't want to change action for such command:
It's possible that some users suppose that it must work that way as it works now. If we change it now, the some working scripts will not work for them anymore.
The idea was that if we call simple command:
7-zip processes all files for these commands:
So no_file_mask works same was as
*universal mask.If we change the behavior for
acommand, then there will be difference betweenaandxcommands .I was added notes about this issues to usage text on Debian package.
I also attach a patch file for this fix.
Can you at least modify the behavior of "7z a foo.7z" so that 7z doesn't automatically add the archive to itself?
Here's the behavior of dar, which also defaults to automatic archiving of the current directory:
$ dar -c archive
WARNING! The archive is located in the directory to backup, this may create an endless loop when the archive will try to save itself. You can either add -X "archive.*.dar" on the command line, or change the location of the archive (see -h for help). Do you really want to continue? [return = YES | Esc = NO]
Also, "7z d foo.7z" (without any file selector) defaults to deleting everything in "foo.7z". This is bad when user accidentally presses enter without typing file selector.
Maybe you can add a -f(orce) switch for dangerous actions, such as delete everything or when the archive tries to save itself?.
You're not the only one who thinks this policy is overboard.
I got caught in a loop of creating increasingly larger archives when forgot to enter file list or had some error in script that passed empty file list.
I would rather to get an error than to compress everything as it is.
Considering that there are multiple, other ways (below) to pass all current directory as file list I would welcome the end of this policy.