That method is quite an overkill by the looks of it. You could simply do something like this (providing you have an bash/ksh that supports this form of parameter expansion):
fs="/one/two/three/"
tmp=${fs%/}
echo ${tmp:-/} # The expected result
The first substitution trims off a trailing / from whatever the input string is.
The second substitution assigns the value / if the input is null, i.e. it used to be just / before it was trimmed to nothing. The first code suggestion just merges these two together.
Hi Yoda, the / character needs to be escaped within an awk regex constant expression that is terminated by two slashes, even within a bracket expression: