* ${i:r}-question @ 2005-08-26 16:32 Meino Christian Cramer 2005-08-27 17:11 ` ${i:r}-question zzapper 2005-08-27 20:44 ` ${i:r}-question Bart Schaefer 0 siblings, 2 replies; 7+ messages in thread From: Meino Christian Cramer @ 2005-08-26 16:32 UTC (permalink / raw) To: zsh-users Hi, I am currently wrting a little shell script, which encapsulates the new "arepack" addition of atool-0.31.0 (nice tool! use it! :O))). The shell script should repack all archives given on the command line to *.tar.7z _or_ *.7z archives -- depending on whether the original archive was a plain *.bz2 (one file compressed with bzip2) or a *.tar.bz2 (tar archive with bzip2 compressed). Experimenting with expressions similiar to afile="test.tar.bz2" echo ${afile:e} I am wondering, whether it would possible to strip off more than one "instance" of extension ("tar.bz2" instead of "bz2") from "$afile" without using somthing like echo ${${afile:e}} since this would depends on knowing whether it is a *.bz2 or a *.tar.bz2 archive before evaluating the expression, which reveals exactly this information...... :) Thank you very much in advance for any help and enlightment ! ;O))) Have a nice weekend ! Meino ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-26 16:32 ${i:r}-question Meino Christian Cramer @ 2005-08-27 17:11 ` zzapper 2005-08-27 17:41 ` ${i:r}-question Meino Christian Cramer 2005-08-27 20:44 ` ${i:r}-question Bart Schaefer 1 sibling, 1 reply; 7+ messages in thread From: zzapper @ 2005-08-27 17:11 UTC (permalink / raw) To: zsh-users On Fri, 26 Aug 2005 18:32:16 +0200 (CEST), wrote: >Hi, > > I am currently wrting a little shell script, which encapsulates the > new "arepack" addition of atool-0.31.0 (nice tool! use it! :O))). > Sorry no answer to your query but :- Presumably:- Atool - Script for managing file archives atool manages file archives (tar, tar+gzip, zip, etc). 'aunpack' extracts files from an archive, andt overcomes the dreaded "multiple files in archive root" problem by first extracting to a unique subdirectory, and then moving back the files if possible. aunpack also prevents local files from being overwritten by mistake. Other commands provided are apack (for creating archives), als (for listing files in archives), and acat (for extracting files to stdout). Can't see where you'd use it? -- zzapper Success for Techies and Vim,Zsh tips http://SuccessTheory.com/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-27 17:11 ` ${i:r}-question zzapper @ 2005-08-27 17:41 ` Meino Christian Cramer 0 siblings, 0 replies; 7+ messages in thread From: Meino Christian Cramer @ 2005-08-27 17:41 UTC (permalink / raw) To: david; +Cc: zsh-users From: zzapper <david@tvis.co.uk> Subject: Re: ${i:r}-question Date: Sat, 27 Aug 2005 18:11:41 +0100 Hi David ! :) Thanks for your reply. Hrmmm....may be I struggled over my own limited English in this conversation. With "(nice tool! use it! :O)))" I meant "Atool is a nice tool and I want to recommend it." Unfortunately I dont know exactly, whether I understood you right: "Can't see where you'd use it?" Do you want to know why/when I use it? If so: A comparison: Packing a sourcetree with p7zip, preserving as much information a possible, conventional way: tar cvf - <sourcetree> | 7z a -si <sourcetree>.7z - With apack: apack <sourcetree>.7z <sourcetree> I think, this clearifies things a little ?! :O) Keep zshing and have a nice weekend! Meino > On Fri, 26 Aug 2005 18:32:16 +0200 (CEST), wrote: > > >Hi, > > > > I am currently wrting a little shell script, which encapsulates the > > new "arepack" addition of atool-0.31.0 (nice tool! use it! :O))). > > > Sorry no answer to your query but :- > > Presumably:- > > Atool - Script for managing file archives > atool manages file archives (tar, tar+gzip, zip, etc). 'aunpack' extracts files from an archive, > andt overcomes the dreaded "multiple files in archive root" problem by first extracting to a unique > subdirectory, and then moving back the files if possible. aunpack also prevents local files from > being overwritten by mistake. Other commands provided are apack (for creating archives), als (for > listing files in archives), and acat (for extracting files to stdout). > > Can't see where you'd use it? > > -- > zzapper > Success for Techies and Vim,Zsh tips > http://SuccessTheory.com/ > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-26 16:32 ${i:r}-question Meino Christian Cramer 2005-08-27 17:11 ` ${i:r}-question zzapper @ 2005-08-27 20:44 ` Bart Schaefer 2005-08-28 0:55 ` ${i:r}-question Meino Christian Cramer 1 sibling, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2005-08-27 20:44 UTC (permalink / raw) To: zsh-users On Aug 26, 6:32pm, Meino Christian Cramer wrote: } } I am currently wrting a little shell script, which encapsulates the } new "arepack" addition of atool-0.31.0 (nice tool! use it! :O))). I'm glad you answered zzapper's question because I was scratching my head over why it made a difference if the bzip'd file was also tar'd. } I am wondering, whether it would possible to strip off more than one } "instance" of extension ("tar.bz2" instead of "bz2") from "$afile" You mean e.g. ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} except that you don't want to have to enumerate (7z|bz2|gz)? Otherwise I'm not clear on the question. Incidentally if it's important to know about the "tar" part, then have you considered what to do with e.g. ".tgz" files? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-27 20:44 ` ${i:r}-question Bart Schaefer @ 2005-08-28 0:55 ` Meino Christian Cramer 2005-08-28 3:07 ` ${i:r}-question Bart Schaefer 0 siblings, 1 reply; 7+ messages in thread From: Meino Christian Cramer @ 2005-08-28 0:55 UTC (permalink / raw) To: schaefer; +Cc: zsh-users From: Bart Schaefer <schaefer@brasslantern.com> Subject: Re: ${i:r}-question Date: Sat, 27 Aug 2005 20:44:40 +0000 Hi Bart , :) thanks for your reply ! :O) To "unbroke" my broken English a little bit more I will try to tell a little more of my (a little longish) "archiver/compressor"-story. p7zip is a data compressor, which has a compression ratio even better than bzip2 (!). Since "space" on my harddisk is a seldom guest, I was happy, that Oskar, the author of atool has implemented the "arepack" tool in addition to all the other very handy tools of his atool suit. In opposite to bzip2/gzip p7zip is able to build archives of more than one file. Since it originates in the Windows world, it does not reconstruct certain attributes like gid and uid of the files of such an p7zip-only-many-files archive. The author of p7zip recommends to make a tar archive first and then compress it with p7zip for backup purposes on Unix/Linux (which I use). The format of the commandline to feed into arepack is as follows: arepack -F<new target archive form> -e <old archive/s> For *.tar.gz archives it would be: arepack -F.tar.7z -e zsh-4.2.5.tar.gz but if you get a single file compressed with gzip for example, it would be: arepack -F.7z -e zsh-doc-4.2.5.gz Therefore I was looking for a zsh script expression -- without the need to use "big brothers" like sed, perl etc -- which simply gives me "the whole extension string" in one turn, without to destinguish between the 2-extension form like ".tar.gz" from the 1-extension-form like ".gz" in the script code itsself in beforehand. Additionally it would be nice, if the code would give me the information, whether it has found a 2- or an 1-extension form. Or shorter: Output: Input: +------> complete extension | <filename> -----> script ---+ | +------> info whether it is an 1- or 2-extension form The code fragment ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} would fail on files, which are of the pattern zsh-4.2.5-doc.bz2 (only one extension) or? (and all files, which are no Makefiles.... ;O) If I would have such an code fragment as desribed above, I would simply replace any ".tgz" string in a ".tar,gz" string afterwards (.tbz -> .tar.bz2 accordingly) and I would check for a ".tgz" string and then generate a ".tar.7z" string for the "-F<new format> part of the commandline to be fed into arepack. Dont hesitate to mail and ask again, Bart, if something is unclear -- English isn't my mother's tongue...sorry. Have a nice weekend and thank you very much for your help and patience with my English in advance ! :) Meino > On Aug 26, 6:32pm, Meino Christian Cramer wrote: > } > } I am currently wrting a little shell script, which encapsulates the > } new "arepack" addition of atool-0.31.0 (nice tool! use it! :O))). > > I'm glad you answered zzapper's question because I was scratching my > head over why it made a difference if the bzip'd file was also tar'd. > > } I am wondering, whether it would possible to strip off more than one > } "instance" of extension ("tar.bz2" instead of "bz2") from "$afile" > > You mean e.g. ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} except that you > don't want to have to enumerate (7z|bz2|gz)? Otherwise I'm not clear > on the question. > > Incidentally if it's important to know about the "tar" part, then have > you considered what to do with e.g. ".tgz" files? > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-28 0:55 ` ${i:r}-question Meino Christian Cramer @ 2005-08-28 3:07 ` Bart Schaefer 2005-08-28 5:12 ` ${i:r}-question Meino Christian Cramer 0 siblings, 1 reply; 7+ messages in thread From: Bart Schaefer @ 2005-08-28 3:07 UTC (permalink / raw) To: zsh-users On Aug 28, 2:55am, Meino Christian Cramer wrote: } Subject: Re: ${i:r}-question } } The code fragment } } ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} } } would fail on files, which are of the pattern } } zsh-4.2.5-doc.bz2 (only one extension) What makes you think so? schaefer[501] afile=zsh-4.2.5-doc.bz2 schaefer[502] print ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} bz2 schaefer[503] afile=zsh-4.2.5-doc.tar.gz schaefer[504] print ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} tar.gz Note that (.tar|) has an empty sub-pattern to the right of the vertical bar, so it means ".tar or nothing". } or? (and all files, which are no Makefiles.... ;O) I'm afraid I don't understand what you mean about files that are not Makefiles. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ${i:r}-question 2005-08-28 3:07 ` ${i:r}-question Bart Schaefer @ 2005-08-28 5:12 ` Meino Christian Cramer 0 siblings, 0 replies; 7+ messages in thread From: Meino Christian Cramer @ 2005-08-28 5:12 UTC (permalink / raw) To: schaefer; +Cc: zsh-users From: Bart Schaefer <schaefer@brasslantern.com> Subject: Re: ${i:r}-question Date: Sun, 28 Aug 2005 03:07:09 +0000 Hi Bart ! > On Aug 28, 2:55am, Meino Christian Cramer wrote: > } Subject: Re: ${i:r}-question > } > } The code fragment > } > } ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} > } > } would fail on files, which are of the pattern > } > } zsh-4.2.5-doc.bz2 (only one extension) > > What makes you think so? > > schaefer[501] afile=zsh-4.2.5-doc.bz2 > schaefer[502] print ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} > bz2 > schaefer[503] afile=zsh-4.2.5-doc.tar.gz > schaefer[504] print ${${(M)afile%%(.tar|).(7z|bz2|gz)}#.} > tar.gz > Note that (.tar|) has an empty sub-pattern to the right of the vertical > bar, so it means ".tar or nothing". Ah, I see... !!! ENLIGHTMENT! (my previous reply...it was to deep in the night....sorry) > > } or? (and all files, which are no Makefiles.... ;O) > > I'm afraid I don't understand what you mean about files that are not > Makefiles. > Oh shit...again a fault of mine (I should not write mails in the night...) --> ${(M)afile was {${(M)akefile in my eyes... I will try to make my script run with your suggestions, Bart ! Thanks a lot fo ryour help ! Keep zshing! Meino ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-28 5:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-08-26 16:32 ${i:r}-question Meino Christian Cramer 2005-08-27 17:11 ` ${i:r}-question zzapper 2005-08-27 17:41 ` ${i:r}-question Meino Christian Cramer 2005-08-27 20:44 ` ${i:r}-question Bart Schaefer 2005-08-28 0:55 ` ${i:r}-question Meino Christian Cramer 2005-08-28 3:07 ` ${i:r}-question Bart Schaefer 2005-08-28 5:12 ` ${i:r}-question Meino Christian Cramer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).