source: tags/confman-1.5.6a2/abspath @ 64

Revision 64, 484 bytes checked in by ccowart, 6 years ago (diff)

Separating out abspath to incorporate sudo.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1#! /bin/bash
2#
3# This script takes an argument and prints to STDOUT the absolute pathname
4# of that argument.
5#
6# Example: abspath ../postfix.conf
7#
8# Author: Chris Cowart <ccowart@rescomp.berkeley.edu>
9# Date: 12 April 2006
10#
11# $Id$
12
13function abspath {
14  local file="$1"
15  local dir
16  if [ -d $file ] ; then
17    dir=`cd $file >/dev/null; echo \$PWD`
18    echo "$dir"
19  else
20    dir=`cd $(dirname $file) >/dev/null ; echo \$PWD`
21    echo "$dir/$(basename "$file")"
22  fi
23}
24
25abspath $1
26
Note: See TracBrowser for help on using the repository browser.