Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Jens Schweikhardt Newsgroups: comp.unix.shell,comp.unix.programmer,comp.programming.contests Subject: Re: The First Pure Shell Contest (PUSH): relativepath Date: 19 Aug 2011 19:12:58 GMT Lines: 48 Sender: Jens Schweikhardt Message-ID: <9b7qtqFiseU1@mid.individual.net> References: <9b7kg7F3njU1@mid.individual.net> X-Trace: individual.net OsK3qT+qrev7rNuEuOBqAAAoKVi81RSuKVTy8dTmEMLadSCP7z X-Orig-Path: not-for-mail Cancel-Lock: sha1:+a0NZ+vC/uP0945HEqg3JvR3Bm4= User-Agent: tin/1.9.6-20101126 ("Burnside") (UNIX) (FreeBSD/9.0-CURRENT (i386)) Xref: x330-a1.tempe.blueboxinc.net comp.unix.shell:1719 comp.unix.programmer:1159 comp.programming.contests:10 In comp.unix.programmer Stephane CHAZELAS wrote: # 2011-08-19, 17:23(+00), Jens Schweikhardt: # [...] #> The goal is to show the #> absurdity of forking and nonportable constructs when a nice and small #> pure shell solution solves the problem just as well. # # What do you mean? The shell is is a command interpreter, it's # whole raison d'etre is to run commands. But commands can be built-in or external. External commands are forked and potentially much slower than an equivalent built-in. Was the "Motivation" paragraph that hard to understand? # Awk and Perl are built in my POSIX shell and not "[". Which am I # allowed to use? Then our understanding of the term "built-in" is very different and I'm afraid it is yours that is the non-conventional one. #> Write a POSIX shell function named 'relativepath' which takes as #> arguments two absolute canonicalized pathnames, and stores the relative #> path from the first to the second in the variable "result" or "." when #> the arguments are the same. Example: relativepath /foo/bar /foo/baz sets #> result to "../baz". # # You mean /foo/bar/../baz is meant to be /foo/baz? On my system, # it's /usr/local/baz as /foo/bar is a symlink to /usr/local/bin. No. I mean what my definition of "canonical" said. #> A canonicalized pathname is one that contains no "." #> or ".." directories and no occurrences of "//"; only the root directory #> may end with "/". # # You probably want to add as requirement that none of the # components of either path should be a symbolic link. The relative path is purely textual. The names don't even have to exist in the file system. Maybe I should have added that to the task description. Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped)