# Emulate the POSIX basename command to extract just the last component
# of a pathname, deleting any suffix, if specified.
# Usage: basename string [ suffix ]
# Copyright (c) 1996 by Hamilton Laboratories. All rights reserved.
proc basename( string, suffix )
local base, i, j
@ base = $string:t
if (base == "") @ base = "\"
if (suffix == "" && suffix != base) return base
@ i = strlen(base)
@ j = strlen(suffix)
return i > j && lower(substr(base, i - j + 1)) == lower(suffix) ? ^
substr(base, 1, i - j) : base
end
basename $argv
Hamilton C shell |
Free Updates |
Free Demo Software |
Win32 Training
Y2K |
Customer Testimonials |
On-line Hamilton C shell User Guide
Home |
Email |
Support |
Company Profile |
Distributors |
Links
Copyright © 1997-2001 by Hamilton Laboratories.
All rights reserved.
You are visitor number
660.
This page was last modified August 14, 2001.