General TC > Programming & Scripting - Unofficial

uncompress script with 7z

<< < (2/3) > >>

roberts:
7z is not part of the base. You should check if 7z is available and if not display such, pause, then exit.

mikshaw:
Another bit of picky....

[ -z "$1" ] && exit 1 tests if $1 is an empty string.  This is essentially the same as testing whether or not the first argument exists.  This is fine if you just want an arbitrary string.  In this case, however, you want specifically a filename, so it might be better to test for an existing regular file (f):
[ -f "$1" ] || exit 1

Take note that using "$1" will exit on filenames that contain spaces...although since I hate spaces in filenames I typically don't bother addressing this issue myself =op

3rd:  FILE="${1##*/}" is the same as FILE=`basename $1`, which I think is more universally supported.  It's probably not uch of an issue. EDIT: I guess it doesn't make a difference which one you use

jls:

--- Quote from: mikshaw on September 26, 2009, 10:02:11 AM ---.....
[ -f "$1" ] || exit 1......

3rd:  FILE="${1##*/}" is the same as FILE=`basename $1`, which I think is more universally supported.  It's probably not uch of an issue.

--- End quote ---
the -f : done
what do u mean by universally supported?

mikshaw:
I was thinking ${parameter##string} was specific to bash, but it turns out I was wrong....I guess I was confusing it with $(command)
You can ignore that one.

^thehatsrule^:

--- Quote from: bmarkus on September 25, 2009, 06:03:48 AM ---p7zip is version 4.65 in the repo, released in February while current at http://sourceforge.net/projects/p7zip/files/ is 9.04

Now it supports XZ archives.

Numbering scheme changed  :(

--- End quote ---
FYI: I think 7zip 9.x is currently in beta

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version