From: xahlee on
is there a way to call the unix zip utility programmatically with full
path as arguments but yet does not have the created zip archive
contain all the nested parent dir?

some detail here:

zip archive created by the zip utility will include the full path up
to root dir when called with full path arguments.

e.g.

zip -r /Users/xah/web/diklo/xx-htmlize-study.zip /Users/xah/web/diklo/
xx-htmlize-study
zip -r /Users/xah/web/diklo/xx-htmlize-study.zip /Users/xah/web/diklo/
xx-htmlize-study

the solution is not to use full path but cd to the dir first. e.g.

cd /Users/xah/web/diklo
zip -r xx-htmlize-study.zip xx-htmlize-study

but i need to call zip programmatically in elisp. I noticed this
works:

(setq default-directory "/Users/xah/web/diklo/")
(shell-command (concat "zip -r " zipCoreName ".zip " zipCoreName))

however, not sure what mechanism it works. Does emacs passes the
current dir into the shell before calling shell-command, then the zip
utility picks it up from shell env?

also, i often needs to do one-line unix command of the form
find . ... | xargs -l -i zip -r "{}.zip" "{}"

But the reliance on notion of current directory makes this one-liner
impossible ... (for context, using tar gzip with “tar cfz” will work
fine.)

Is there a solution on this?

i was hoping the zip util has a option to set a base dir to be
considered the current dir, but couldn't find it in its man page, or
how to get what i want above.

Thanks in advance.

Xah
∑ http://xahlee.org/

☄
From: Lew Pitcher on
In comp.unix.programmer, xahlee(a)gmail.com wrote:

> is there a way to call the unix zip utility programmatically with full
> path as arguments but yet does not have the created zip archive
> contain all the nested parent dir?

Why not just use the -j option to "junk the path"

-j Store just the name of a saved file (junk the path), and do
not store directory names. By default, zip will store the full
path (relative to the current path).


See the zip(1) manpage for details
[snip]

HTH
--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------


From: xahlee on
> Why not just use the -j option to "junk the path"
>
> -j Store just the name of a saved file (junk the path), and do
> not store directory names. By default, zip will store the full
> path (relative to the current path).

I tried the -j option, however, the archive will be just a list of
flat files.

Xah
∑ http://xahlee.org/

☄

On Jun 26, 12:01 pm, Lew Pitcher <lpitc...(a)teksavvy.com> wrote:
> In comp.unix.programmer, xah...(a)gmail.com wrote:
> > is there a way to call the unix zip utility programmatically with full
> > path as arguments but yet does not have the created zip archive
> > contain all the nested parent dir?
>
> Why not just use the -j option to "junk the path"
>
> -j Store just the name of a saved file (junk the path), and do
> not store directory names. By default, zip will store the full
> path (relative to the current path).
>
> See the zip(1) manpage for details
> [snip]
>
> HTH
> --
> Lew Pitcher
>
> Master Codewright & JOAT-in-training | Registered Linux User #112576http://pitcher.digitalfreehold.ca/ | GPG public key available by request
> ---------- Slackware - Because I know what I'm doing. ------