Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #202104 > unrolled thread

Archiving content of a directory on a DVD-R.

Started bypeter@easthope.ca
First post2018-11-04 16:50 +0100
Last post2018-11-14 16:40 +0100
Articles 20 on this page of 29 — 7 participants

Back to article view | Back to linux.debian.user


Contents

  Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-04 16:50 +0100
    Re: Archiving content of a directory on a DVD-R. "Thomas Schmitt" <scdbackup@gmx.net> - 2018-11-04 19:00 +0100
      Re: Archiving content of a directory on a DVD-R. Jonathan Dowland <jmtd@debian.org> - 2018-11-07 12:30 +0100
        Re: Archiving content of a directory on a DVD-R. "Thomas Schmitt" <scdbackup@gmx.net> - 2018-11-07 13:10 +0100
          Re: Archiving content of a directory on a DVD-R. Jonathan Dowland <jmtd@debian.org> - 2018-11-07 15:40 +0100
    Re: Archiving content of a directory on a DVD-R. David Christensen <dpchrist@holgerdanske.com> - 2018-11-05 00:20 +0100
    Re: Archiving content of a directory on a DVD-R. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-05 15:10 +0100
      Re: Archiving content of a directory on a DVD-R. <tomas@tuxteam.de> - 2018-11-05 15:40 +0100
    Re : Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-07 23:40 +0100
      Re: Archiving content of a directory on a DVD-R. "Thomas Schmitt" <scdbackup@gmx.net> - 2018-11-08 09:00 +0100
    Re: Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-08 00:00 +0100
      pushd/podp (was Re: Archiving content of a directory on a DVD-R.) Jonathan Dowland <jmtd@debian.org> - 2018-11-08 10:50 +0100
        Re: pushd/popd peter@easthope.ca - 2018-11-09 16:10 +0100
          Re: pushd/popd Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-09 17:30 +0100
            Re: pushd/popd Jonathan Dowland <jmtd@debian.org> - 2018-11-09 21:50 +0100
          Re: pushd/popd Jonathan Dowland <jmtd@debian.org> - 2018-11-09 17:30 +0100
          Re: pushd/popd peter@easthope.ca - 2018-11-10 19:30 +0100
            Re: pushd/popd David Wright <deblis@lionunicorn.co.uk> - 2018-11-11 07:00 +0100
              Re: pushd/popd Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-12 14:50 +0100
                Re: pushd/popd David Wright <deblis@lionunicorn.co.uk> - 2018-11-12 21:40 +0100
      Re: Archiving content of a directory on a DVD-R. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-08 14:20 +0100
        Re: Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-12 23:00 +0100
          Re: Archiving content of a directory on a DVD-R. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-12 23:20 +0100
            Re: Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-13 03:40 +0100
              Re: Archiving content of a directory on a DVD-R. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-13 14:20 +0100
                Re: Archiving content of a directory on a DVD-R. peter@easthope.ca - 2018-11-13 16:00 +0100
                Re: Archiving content of a directory on a DVD-R. Jonathan Dowland <jmtd@debian.org> - 2018-11-14 11:00 +0100
                  Re: Archiving content of a directory on a DVD-R. Greg Wooledge <wooledg@eeg.ccf.org> - 2018-11-14 14:40 +0100
                    Re: Archiving content of a directory on a DVD-R. Jonathan Dowland <jmtd@debian.org> - 2018-11-14 16:40 +0100

Page 1 of 2  [1] 2  Next page →


#202104 — Archiving content of a directory on a DVD-R.

Frompeter@easthope.ca
Date2018-11-04 16:50 +0100
SubjectArchiving content of a directory on a DVD-R.
Message-ID<wQsP0-xe-13@gated-at.bofh.it>
How is this for archiving the content of a directory?

  pushd <aDirectory> ;
  printf "Insert blank DVD-R."; read t ;
  tar -vcpzf - * | xorriso -indev /dev/sr0 -add -- -commit ;
  xorriso -indev /dev/sr0 -du / -- -toc 2>&1 ;
  xorriso -indev /dev/sr0 -eject ;
  echo "Content of <aDirectory> archived in DVD-R." ;
  popd ;
     
And retrival.

  pushd <anEmptyDirectory> ;
  printf "Insert a DVD-R containing a tar archive."; read t ;
  xorriso -indev /dev/sr0 -toc 2>&1 ;
  xorriso -indev /dev/sr0 -extract / -- | tar -vxf ;
  xorriso -indev /dev/sr0 -eject ;
  popd ;

Comments?  Suggestions?

Thanks,            ... Peter E.

-- 
Message composed and transmitted by software designed to avoid the 
need, overhead and vulnerability of antivirus software.

123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202                                  +1 
http://easthope.ca/Peter.html              Bcc: peter at easthope. ca

[toc] | [next] | [standalone]


#202108

From"Thomas Schmitt" <scdbackup@gmx.net>
Date2018-11-04 19:00 +0100
Message-ID<wQuQO-1GU-7@gated-at.bofh.it>
In reply to#202104
Hi,

peter@easthope.ca wrote:
>   printf "Insert blank DVD-R."; read t ;
>   tar -vcpzf - * | xorriso -indev /dev/sr0 -add -- -commit ;

Writing the tar stream to DVD-R is a classical use case of cdrecord or wodim.
So:

  tar -vcpzf - * | xorriso -as cdrecord -v dev=/dev/sr0 -eject fs=16m -

This will not create a filesystem around the tar archive. So the planned
xorriso runs with command -indev would then go on strike:

>   xorriso -indev /dev/sr0 -du / -- -toc 2>&1 ;
>   xorriso -indev /dev/sr0 -eject ;

Retrieval is then just a matter of tar and the Linux sr driver:

  tar xvzf /dev/sr0

Of course, this will not give you quick access to single files and even
getting a list of content will last several minutes, if the tar archive
fills most of the DVD:

  tar tvzf /dev/sr0

-------------------------------------------------------------------------

If you want to make use of xorriso's capability to create a mountable ISO
filesystem with a copy of your directory, then you do not need tar.

  xorriso -for_backup -outdev /dev/sr0 -map . / \
          -close on -commit \
          -toc -check_md5 failure -- \
          -eject all

This run acquires /dev/sr0 by command "-outdev". Command "-map . /" maps
the directory tree of the current rd disk directory to the /-directory tree
of the ISO 9660 filesystem on the DVD-R. 
By command "-for_backup" it will record MD5 checksums for the whole
filesystem and for each single data files in the filesystem.

Command "-close on" causes the DVD-R to become unwritable after the burn
run is completed. (If you omit it then the DVD stays appendable for more
sessions.) Command "-commit" performs the burn run.

Command "-toc" will afterwards print an overview of the result after the
new ISO filesystem was assesd by xorriso.
Command "-check_md5 failure --" reads the freshly written blocks and compare
their MD5 with the recorded checksum in the ISO. In case of mismatch it
will throw an event of severity "failure", which will abort the xorriso run.
If not aborted, the drive will be told by "-eject all" to eject the tray.
(It needs to have a motor for that, of course.)

Retrieval:

If not your friendly desktop mounts the DVD automatically on insertion:

  mount /dev/sr0 /mnt/iso

Then use normal file tools like "ls", "cp", or a desktop file manager to
copy the files to hard disk or just to let your application read them from
the mounted directory directly.

Verifying of the medium after a while on the shelf:

  xorriso -for_backup -indev /dev/sr0 -check_media --


Have a nice day :)

Thomas

[toc] | [prev] | [next] | [standalone]


#202218

FromJonathan Dowland <jmtd@debian.org>
Date2018-11-07 12:30 +0100
Message-ID<wRuc1-606-1@gated-at.bofh.it>
In reply to#202108
On Sun, Nov 04, 2018 at 06:48:45PM +0100, Thomas Schmitt wrote:
>If you want to make use of xorriso's capability to create a mountable ISO
>filesystem with a copy of your directory, then you do not need tar.
>
>  xorriso -for_backup -outdev /dev/sr0 -map . / \
>          -close on -commit \
>          -toc -check_md5 failure -- \
>          -eject all

This is very, very good advice. The one question I had when reading it
was to what extent this faithfully recorded all the metadata for the
files that are selected. But I answered that via the xorriso(1) manpage,
and "-for_backup" selects all the necessary extensions etc. to do the
best job possible.

So, +1 for this approach - *especially* the -check_md5 step.


-- 

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.

[toc] | [prev] | [next] | [standalone]


#202220

From"Thomas Schmitt" <scdbackup@gmx.net>
Date2018-11-07 13:10 +0100
Message-ID<wRuOK-6sa-11@gated-at.bofh.it>
In reply to#202218
Hi,

> "-for_backup" selects all the necessary extensions etc. to do the
> best job possible.

Regrettably i see few chances to get an interpreter for the extra info
into Linux or other kernels. So for restoring ACL, xattr, or hard link
relations, one will have to use commands -osirrox "on" and -extract.
This also helps to work around kernel shortcommings on Solaris and the BSDs.


Have a nice day :)

Thomas

[toc] | [prev] | [next] | [standalone]


#202228

FromJonathan Dowland <jmtd@debian.org>
Date2018-11-07 15:40 +0100
Message-ID<wRx9U-7IF-9@gated-at.bofh.it>
In reply to#202220
On Wed, Nov 07, 2018 at 01:05:46PM +0100, Thomas Schmitt wrote:
>Regrettably i see few chances to get an interpreter for the extra info
>into Linux or other kernels. So for restoring ACL, xattr, or hard link
>relations, one will have to use commands -osirrox "on" and -extract.
>This also helps to work around kernel shortcommings on Solaris and the BSDs.

This would be a really interesting piece of work and if I wasn't already
crazy busy (full time job, young daughter, part time PhD, mostly ignored
Debian responsibilities, proofreading a book…) I'd jump on it. But if
you are prepared to mail me privately some further technical details, I
might think about scheduling it once I've got a few other things done.
It's been too long since my last kernel contribution (which was trivial
anyway)

>Have a nice day :)

You too ;)

-- 

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.

[toc] | [prev] | [next] | [standalone]


#202117

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2018-11-05 00:20 +0100
Message-ID<wQzQt-5VP-5@gated-at.bofh.it>
In reply to#202104
On 11/4/18 7:29 AM, peter@easthope.ca wrote:
> How is this for archiving the content of a directory?
> 
>    pushd <aDirectory> ;
>    printf "Insert blank DVD-R."; read t ;
>    tar -vcpzf - * | xorriso -indev /dev/sr0 -add -- -commit ;
>    xorriso -indev /dev/sr0 -du / -- -toc 2>&1 ;
>    xorriso -indev /dev/sr0 -eject ;
>    echo "Content of <aDirectory> archived in DVD-R." ;
>    popd ;

I tried to find the simplest way to burn files to an optical disc using 
xorriso(1), and then put the incantation into a script.  Here are the 
essential lines:

     #!/bin/bash
     DEVICE="/dev/cdrom"
     VOLID=...
     xorriso -outdev  "$DEVICE"  -volid  "$VOLID"  -map_l $PWD / $@
     eject  "$DEVICE"


Basically: invoke xorriso with two options and one command that consumes 
the command-line arguments (paths to files).


Note that there is no tar or gzip involve, just a straight copy from one 
file system to another.  (I typically create tarballs and matching 
checksum files on HDD, and then burn those to optical.)


> And retrival.
> 
>    pushd <anEmptyDirectory> ;
>    printf "Insert a DVD-R containing a tar archive."; read t ;
>    xorriso -indev /dev/sr0 -toc 2>&1 ;
>    xorriso -indev /dev/sr0 -extract / -- | tar -vxf ;
>    xorriso -indev /dev/sr0 -eject ;
>    popd ;

I put the disc into the drive, wait for Thunar (Xfce) to show the volume 
ID on the left pane, and then click on it.  This mounts the disc at 
/media/cdrom0.  I can then use whatever tools I like to access the 
contents of the disc.


Or, from the terminal:

2018-11-04 14:50:42 dpchrist@po ~
$ mount /media/cdrom0
mount: /dev/sr0 is write-protected, mounting read-only

2018-11-04 14:50:54 dpchrist@po ~
$ l /media/cdrom0
./		     README.source  dists/     install/      setup.exe
../		     README.txt     doc/       install.386/  tools/
.disk/		     autorun.inf    efi/       isolinux/     win32-loader.ini
README.html	     boot/	    firmware/  md5sum.txt
README.mirrors.html  css/	    g2ldr      pics/
README.mirrors.txt   debian@	    g2ldr.mbr  pool/

2018-11-04 14:51:44 dpchrist@po ~
$ eject
eject: unable to open `/dev/sr0'

2018-11-04 15:06:10 dpchrist@po ~
$ eject /mnt/cdrom0
eject: unable to find or open device for: `/mnt/cdrom0'


eject(1) doesn't seem to work, so I press the eject button the drive to 
get the disc out.


David

[toc] | [prev] | [next] | [standalone]


#202137

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-11-05 15:10 +0100
Message-ID<wQNJL-5YC-1@gated-at.bofh.it>
In reply to#202104
On Sun, Nov 04, 2018 at 07:29:53AM -0800, peter@easthope.ca wrote:
> How is this for archiving the content of a directory?
> 
>   pushd <aDirectory> ;
>   printf "Insert blank DVD-R."; read t ;
>   tar -vcpzf - * | xorriso -indev /dev/sr0 -add -- -commit ;

Be aware that the * glob will probably miss filenames beginning with
a dot.  Since you're using pushd, which is a bash extension, this is
probably a bash script.  Therefore you might consider using

shopt -s dotglob

inside the script, to make the * glob include "dot files".  That's
assuming you want to retain the current archive appearance.

The alternative would be to use . instead of * as tar's starting
point.  This would change your archive appearance from

.bashrc
bin/foo
lib/libbar.a

to

./.bashrc
./bin/foo
./lib/libbar.a

[toc] | [prev] | [next] | [standalone]


#202140

From<tomas@tuxteam.de>
Date2018-11-05 15:40 +0100
Message-ID<wQOcO-67T-7@gated-at.bofh.it>
In reply to#202137

[Multipart message — attachments visible in raw view] — view raw

On Mon, Nov 05, 2018 at 09:04:58AM -0500, Greg Wooledge wrote:
> On Sun, Nov 04, 2018 at 07:29:53AM -0800, peter@easthope.ca wrote:
> > How is this for archiving the content of a directory?
> > 
> >   pushd <aDirectory> ;
> >   printf "Insert blank DVD-R."; read t ;
> >   tar -vcpzf - * | xorriso -indev /dev/sr0 -add -- -commit ;
> 
> Be aware that the * glob will probably miss filenames beginning with
> a dot [...]

Greg, as ever :-)

No, seriously: thanks for your constant work here. I do learn quite a
bit from your posts, even if I consider myself as somewhat seasoned.

> inside the script, to make the * glob include "dot files".  That's
> assuming you want to retain the current archive appearance.
> 
> The alternative would be to use . instead of * as tar's starting
> point.  This would change your archive appearance from

+1 on .

> .bashrc
> bin/foo
> lib/libbar.a
> 
> to
> 
> ./.bashrc
> ./bin/foo
> ./lib/libbar.a

If you don't want that, you can use (GNU) tar's wonderful file path
transformation magic, e.g.:

  tar -vcpzf - --xform='s/^\.\///' . | xorriso ...

(it takes an sed expression there).

Cheers
-- t

[toc] | [prev] | [next] | [standalone]


#202240 — Re : Archiving content of a directory on a DVD-R.

Frompeter@easthope.ca
Date2018-11-07 23:40 +0100
SubjectRe : Archiving content of a directory on a DVD-R.
Message-ID<wREEq-3R0-5@gated-at.bofh.it>
In reply to#202104
From:	Lee <ler762@gmail.com>
Date:	Sun, 4 Nov 2018 12:25:43 -0500
> any chance there's a symlink in the directory? that you want archived?
> tar -h
>   Follow symlinks; archive and dump the files they point to.

Thanks for mentioning that. The directory is for plain old files of 
data and a few subdirectories.  Subdirectories are excluded from the 
first stage of backup.  I can't think of a reason for a symlink to 
exist but will keep the possibility in mind.  An exception is a likely 
source of trouble.

Regards,                         ... Peter E.



-- 
Message composed and transmitted by software designed to avoid the 
need, overhead and vulnerability of antivirus software.

123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202                                  +1 
http://easthope.ca/Peter.html              Bcc: peter at easthope. ca

[toc] | [prev] | [next] | [standalone]


#202245

From"Thomas Schmitt" <scdbackup@gmx.net>
Date2018-11-08 09:00 +0100
Message-ID<wRNom-IE-7@gated-at.bofh.it>
In reply to#202240
Hi,

Lee <ler762@gmail.com> wrote:
> > any chance there's a symlink in the directory? that you want archived?
> > tar -h
> >   Follow symlinks; archive and dump the files they point to.

peter@easthope.ca wrote:
> I can't think of a reason for a symlink to 
> exist but will keep the possibility in mind.  An exception is a likely 
> source of trouble.

Actually i think that symbolic links should be backuped as what they are.

Backing up link targets instead will prevent recreating of the link
relation at restore time. If the link target or link siblings are also part
of the backup, then they will be backuped and restored as duplicates.

Said this, if you use xorriso for making an ISO 9660 you can control this
by command -follow. Default is

  -follow pattern:mount:limit=100

which will follow links during resolving of search patterns (as would the
shell do), will follow a sub tree into a different mounted filesystem,
and limit link chain length to 100 in order to avoid link loops.

If you want to follow symbolic links inside tress, perform before the
first -map command:

  -follow link:mount:limit=100

If you do not want this but only want to record the link targets of
program arguments, like $SYMBOLIC_LINK_PATH in

  -map $SYMBOLIC_LINK_PATH $ISO_PATH

then perform

  -follow param:mount:limit=100


Have a nice day :)

Thomas

[toc] | [prev] | [next] | [standalone]


#202241

Frompeter@easthope.ca
Date2018-11-08 00:00 +0100
Message-ID<wREXL-3XP-5@gated-at.bofh.it>
In reply to#202104
I've lost the message but someone mentioned that pushd and popd 
suggest the csh shell.  My backup procedures are shell functions 
rather than scripts and the shell name isn't blatant.  Could be in a 
comment.

push/popd are helpful when a tree structured file system is present.  
Are they in POSIX?  Best avoided?

Thanks,               ... Peter E.



-- 
Message composed and transmitted by software designed to avoid the 
need, overhead and vulnerability of antivirus software.

123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202                                  +1 
http://easthope.ca/Peter.html              Bcc: peter at easthope. ca

[toc] | [prev] | [next] | [standalone]


#202248 — pushd/podp (was Re: Archiving content of a directory on a DVD-R.)

FromJonathan Dowland <jmtd@debian.org>
Date2018-11-08 10:50 +0100
Subjectpushd/podp (was Re: Archiving content of a directory on a DVD-R.)
Message-ID<wRP6O-1MJ-9@gated-at.bofh.it>
In reply to#202241
On Wed, Nov 07, 2018 at 01:52:13PM -0800, peter@easthope.ca wrote:
>push/popd are helpful when a tree structured file system is present.
>Are they in POSIX?  Best avoided?

They are not POSIX, I don't think they are covered by any subsequent
standard either (great opportunity for anyone who wants to contribute to
a future standard I guess!). Originally from csh, they are present in
bash and zsh too, at least; but not dash (by design) and likely not
posh.

-- 

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.

[toc] | [prev] | [next] | [standalone]


#202289 — Re: pushd/popd

Frompeter@easthope.ca
Date2018-11-09 16:10 +0100
SubjectRe: pushd/popd
Message-ID<wSgA1-28q-3@gated-at.bofh.it>
In reply to#202248
    From: Jonathan Dowland <jmtd@debian.org>
    Date: Thu, 8 Nov 2018 09:46:34 +0000
> They are not POSIX, I don't think they are covered by any subsequent
> standard either ...

OK, thanks.

> ... not dash (by design) ... 

Why?  Easy enough to use pushd/popd and easy enough to not it but 
I'm interested in the reasoning behind this choice.

Thanks,                                  ... Peter E.


-- 
Message composed and transmitted by software designed to avoid the 
need, overhead and vulnerability of antivirus software.

123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202                                  +1 
http://easthope.ca/Peter.html              Bcc: peter at easthope. ca

[toc] | [prev] | [next] | [standalone]


#202291 — Re: pushd/popd

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-11-09 17:30 +0100
SubjectRe: pushd/popd
Message-ID<wShPs-2Qh-3@gated-at.bofh.it>
In reply to#202289
On Fri, Nov 09, 2018 at 04:20:57PM +0000, Jonathan Dowland wrote:
> One of dash's design goals is to be a purely POSIX compatible shell*,

Not quite.

> * they actually *do* implement some carefully defined extensions
>  according to the man page

Yeah.  It's not meant to be a litmus test for whether your script refrains
from using any extensions.  It's not a compliance-testing tool.

[toc] | [prev] | [next] | [standalone]


#202297 — Re: pushd/popd

FromJonathan Dowland <jmtd@debian.org>
Date2018-11-09 21:50 +0100
SubjectRe: pushd/popd
Message-ID<wSlT4-5iC-17@gated-at.bofh.it>
In reply to#202291
On Fri, Nov 09, 2018 at 11:26:37AM -0500, Greg Wooledge wrote:
>On Fri, Nov 09, 2018 at 04:20:57PM +0000, Jonathan Dowland wrote:
>> One of dash's design goals is to be a purely POSIX compatible shell*,
>
>Not quite.

Fear not, I'm not confusing it with posh(1). That's my reading of the
dash(1) manpage:

> The current version of dash is in the process of being changed to
> conform with the POSIX 1003.2 and 1003.2a specifications for the
> shell.
…
> Only features designated by POSIX, plus a few Berkeley extensions, are
> being incorporated into this shell.

Greg:
>Yeah.  It's not meant to be a litmus test for whether your script refrains
>from using any extensions.  It's not a compliance-testing tool.

It isn't indeed, that would be posh(1).

-- 

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.

[toc] | [prev] | [next] | [standalone]


#202292 — Re: pushd/popd

FromJonathan Dowland <jmtd@debian.org>
Date2018-11-09 17:30 +0100
SubjectRe: pushd/popd
Message-ID<wShPs-2Qh-5@gated-at.bofh.it>
In reply to#202289
On Fri, Nov 09, 2018 at 06:20:01AM -0800, peter@easthope.ca wrote:
>> ... not dash (by design) ...
>
>Why?  Easy enough to use pushd/popd and easy enough to not it but
>I'm interested in the reasoning behind this choice.

One of dash's design goals is to be a purely POSIX compatible shell*,
so it deliberately does not implement anything else.

* they actually *do* implement some carefully defined extensions
  according to the man page

-- 

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.

[toc] | [prev] | [next] | [standalone]


#202315 — Re: pushd/popd

Frompeter@easthope.ca
Date2018-11-10 19:30 +0100
SubjectRe: pushd/popd
Message-ID<wSGb7-1pD-1@gated-at.bofh.it>
In reply to#202289
*	From: peter@easthope.ca
*	Date: Fri, 09 Nov 2018 06:20:01 -0800
> Why?  Easy enough to use pushd/popd and easy enough to not [use] it but 
> I'm interested in the reasoning behind this choice.

I've read the arguments but no answer to my question.
Is there an intrinsic reason to avoid pushd/popd?  Not 
in POSIX merely because it isn't done yet?

Thanks,             ... Peter E.

-- 
Message composed and transmitted by software designed to avoid the 
need, overhead and vulnerability of antivirus software.

123456789 123456789 123456789 123456789 123456789 123456789 123456789
Tel: +1 360 639 0202                                  +1 
http://easthope.ca/Peter.html              Bcc: peter at easthope. ca

[toc] | [prev] | [next] | [standalone]


#202317 — Re: pushd/popd

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2018-11-11 07:00 +0100
SubjectRe: pushd/popd
Message-ID<wSQWR-8h2-1@gated-at.bofh.it>
In reply to#202315
On Sat 10 Nov 2018 at 09:47:37 (-0800), peter@easthope.ca wrote:
> *	From: peter@easthope.ca
> *	Date: Fri, 09 Nov 2018 06:20:01 -0800
> > Why?  Easy enough to use pushd/popd and easy enough to not [use] it but 
> > I'm interested in the reasoning behind this choice.
> 
> I've read the arguments but no answer to my question.
> Is there an intrinsic reason to avoid pushd/popd?  Not 
> in POSIX merely because it isn't done yet?

Oversimplifying somewhat…

Pushd/popd are really designed for interactive use rather than for
scripts. Hence they remind you of the stack's contents when you use them.

Dash is designed to be small and fast so that it can run scripts faster.
It doesn't need bloating with pushd/popd.

BTW whenever I change directory in scripts, I make sure that I'm in a
subshell by using ( and ), which guarantees that I get back to the
same directory however the script finishes.

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


#202334 — Re: pushd/popd

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-11-12 14:50 +0100
SubjectRe: pushd/popd
Message-ID<wTkLg-2bz-3@gated-at.bofh.it>
In reply to#202317
On Sat, Nov 10, 2018 at 11:58:53PM -0600, David Wright wrote:
> BTW whenever I change directory in scripts, I make sure that I'm in a
> subshell by using ( and ), which guarantees that I get back to the
> same directory however the script finishes.

Depends on the script.  For scripts that change directory more than
once (e.g. a software building script that runs "make" in several
directories, one by one), I concur.  That is sound advice.

For a script that only changes directory once and then does everything
from that directory (e.g. a wrapper), a subshell may be the exact
opposite of what's wanted.  In such cases, you would simply do
"cd /some/where || exit" at the top of the script.

[toc] | [prev] | [next] | [standalone]


#202343 — Re: pushd/popd

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2018-11-12 21:40 +0100
SubjectRe: pushd/popd
Message-ID<wTra1-6n4-3@gated-at.bofh.it>
In reply to#202334
On Mon 12 Nov 2018 at 08:40:15 (-0500), Greg Wooledge wrote:
> On Sat, Nov 10, 2018 at 11:58:53PM -0600, David Wright wrote:
> > BTW whenever I change directory in scripts, I make sure that I'm in a
> > subshell by using ( and ), which guarantees that I get back to the
> > same directory however the script finishes.
> 
> Depends on the script.  For scripts that change directory more than
> once (e.g. a software building script that runs "make" in several
> directories, one by one), I concur.  That is sound advice.
> 
> For a script that only changes directory once and then does everything
> from that directory (e.g. a wrapper), a subshell may be the exact
> opposite of what's wanted.  In such cases, you would simply do
> "cd /some/where || exit" at the top of the script.

Yes, quite a few of my bin/ scripts are like that. But in the aside,
I was really talking about scripts that are contained in OP's shell
functions where, if you pushd but then crash out for whatever reason
without doing the matching popd, you get left in a different directory
from the one you started in. Perhaps s/whenever/when/ and qualifications.

Cheers,
David.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.debian.user


csiph-web