Groups | Search | Server Info | Login | Register


Groups > comp.programming.contests > #8

Re: The First Pure Shell Contest (PUSH): relativepath

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Stephane CHAZELAS <stephane_chazelas@yahoo.fr>
Newsgroups comp.unix.shell, comp.unix.programmer, comp.programming.contests
Subject Re: The First Pure Shell Contest (PUSH): relativepath
Date Fri, 19 Aug 2011 18:13:43 +0000 (UTC)
Organization A noiseless patient Spider
Lines 31
Message-ID <slrnj4t9un.gb7.stephane.chazelas@spam.is.invalid> (permalink)
References <9b7kg7F3njU1@mid.individual.net>
Injection-Date Fri, 19 Aug 2011 18:13:43 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="qzG0Li1iwhS8BRIL3GjZtw"; logging-data="8641"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+I5/RL8i9+rAFSikpJ9dCaToYaK0ExluUOicPeMISE5g=="
User-Agent slrn/pre1.0.0-18 (Linux)
Cancel-Lock sha1:d0y4i20nms0+BPwjzX8sztjUMqQ=
Mail-Copies-To nobody
Xref x330-a1.tempe.blueboxinc.net comp.unix.shell:1717 comp.unix.programmer:1157 comp.programming.contests:8

Cross-posted to 3 groups.

Show key headers only | View raw


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.

Awk and Perl are built in my POSIX shell and not "[". Which am I
allowed to use?

> 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.


> 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.

-- 
Stephane

Back to comp.programming.contests | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <schweikh@schweikhardt.net> - 2011-08-19 17:23 +0000
  Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <stephane_chazelas@yahoo.fr> - 2011-08-19 18:13 +0000
    Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-19 19:12 +0000
      Re: The First Pure Shell Contest (PUSH): relativepath pk <pk@pk.invalid> - 2011-08-19 21:14 +0200
        Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-19 19:29 +0000
          Re: The First Pure Shell Contest (PUSH): relativepath pk <pk@pk.invalid> - 2011-08-19 21:37 +0200
            Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-19 20:04 +0000
              Re: The First Pure Shell Contest (PUSH): relativepath pk <pk@pk.invalid> - 2011-08-19 22:25 +0200
                Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-19 21:08 +0000
  Re: The First Pure Shell Contest (PUSH): relativepath Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-19 19:58 +0100
    Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-19 19:23 +0000
      Re: The First Pure Shell Contest (PUSH): relativepath Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-19 22:18 +0100
  Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <Stephane.CHAZELAS@free.fr> - 2011-08-20 20:07 +0000
    Re: The First Pure Shell Contest (PUSH): relativepath Jens Schweikhardt <usenet@schweikhardt.net> - 2011-08-21 10:43 +0000
    Re: The First Pure Shell Contest (PUSH): relativepath Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-21 15:14 +0100
      Re: The First Pure Shell Contest (PUSH): relativepath Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-08-21 18:28 +0300
      Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <stephane_chazelas@yahoo.fr> - 2011-08-21 16:19 +0000
        Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <stephane_chazelas@yahoo.fr> - 2011-08-21 20:12 +0000
  Re: The First Pure Shell Contest (PUSH): relativepath Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-22 21:15 +0100
    Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <stephane_chazelas@yahoo.fr> - 2011-08-23 18:23 +0000
      Re: The First Pure Shell Contest (PUSH): relativepath Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-23 19:52 +0100
        Re: The First Pure Shell Contest (PUSH): relativepath Stephane CHAZELAS <stephane_chazelas@yahoo.fr> - 2011-08-23 21:56 +0000

csiph-web