Lines 1-5
Link Here
|
1 |
# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ |
1 |
# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ |
2 |
# $FreeBSD: src/etc/rc.subr,v 1.88.2.7 2009/12/15 23:05:16 dougb Exp $ |
2 |
# $FreeBSD$ |
3 |
# |
3 |
# |
4 |
# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. |
4 |
# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. |
5 |
# All rights reserved. |
5 |
# All rights reserved. |
Lines 738-744
Link Here
|
738 |
if [ -n "$_nice" ]; then |
738 |
if [ -n "$_nice" ]; then |
739 |
if [ -z "$_user" ]; then |
739 |
if [ -z "$_user" ]; then |
740 |
_doit="sh -c \"$_doit\"" |
740 |
_doit="sh -c \"$_doit\"" |
741 |
fi |
741 |
fi |
742 |
_doit="nice -n $_nice $_doit" |
742 |
_doit="nice -n $_nice $_doit" |
743 |
fi |
743 |
fi |
744 |
fi |
744 |
fi |
Lines 1063-1069
Link Here
|
1063 |
esac |
1063 |
esac |
1064 |
done |
1064 |
done |
1065 |
} |
1065 |
} |
1066 |
|
1066 |
|
1067 |
# |
1067 |
# |
1068 |
# load_rc_config_var name var |
1068 |
# load_rc_config_var name var |
1069 |
# Read the rc.conf(5) var for name and set in the |
1069 |
# Read the rc.conf(5) var for name and set in the |
Lines 1702-1707
Link Here
|
1702 |
return 0 |
1702 |
return 0 |
1703 |
} |
1703 |
} |
|
|
1704 |
# normalize_path() |
1705 |
# Removes excess components from the file path: |
1706 |
# - single dots, double dots, multiple consecutive slashes |
1707 |
# are correctly collapsed |
1708 |
# Correctly handles spaces in the path components. |
1709 |
# |
1710 |
normalize_path() |
1711 |
{ |
1712 |
echo ${1} | awk '{ |
1713 |
res = ""; |
1714 |
split($0, pieces, "/"); |
1715 |
ii = 0; |
1716 |
len = length(pieces); |
1717 |
for (i = 1; i <= len; i++) { |
1718 |
if (pieces[i] == "") { |
1719 |
if (i == 1) { |
1720 |
# absolute path |
1721 |
res = "/"; |
1722 |
} |
1723 |
} else if (pieces[i] == ".") { |
1724 |
# ignoring dot |
1725 |
} else if (pieces[i] == "..") { |
1726 |
# unwind the path one step |
1727 |
if (ii > 0) { |
1728 |
delete tmp[ii-1]; |
1729 |
ii--; |
1730 |
} |
1731 |
} else { |
1732 |
tmp[ii] = pieces[i]; |
1733 |
ii++; |
1734 |
} |
1735 |
} |
1736 |
for (i = 0; i < length(tmp); i++) res = res tmp[i] "/"; |
1737 |
# remove trailing slash from the result |
1738 |
if (length(res) != 1) { |
1739 |
sub("/$", "", res); |
1740 |
} |
1741 |
print res; |
1742 |
}' |
1743 |
} |
1744 |
|
1704 |
fi |
1745 |
fi |
|
|
1746 |
|
1705 |
_rc_subr_loaded=: |
1747 |
_rc_subr_loaded=: |