shithub: x

ref: 6000627a39a84a28590b12a1cbc5f56272664f95
dir: /path/

View raw version
#!/bin/rc
# x/path -- extract datums from the path
rfork e
if(! ~ $$#* -*)
	wd=$$#*
if not
	wd=`{pwd}
if(! ~ $wd /x/*)
	exit notinx
for(arg){
	switch($arg){
	case -P
		echo $wd | sed 's,/x/[^/]+(.*),\1,'
	case -p
		echo $wd | sed 's,/x/[^/]+/(.*),\1,'
	case -r
		echo $wd | sed 's,(/x/[^/]+).*,\1,'
	case -l
		echo $wd | awk -F/ '{print $3}'
	}
	shift
}