Well, I didn't read the manpage of cp closely enough. There's an option -s (--symbolic-link) to create symbolic links instead of copying. Thanks for the tip about $@ -- that's what I needed! I have a script that should work now. (By the way, I think the reason your example "cp /storage/hammer ." didn't work is because the file didn't exist, so readlink returned "", which doesn't match "/storage". This shouldn't cause any problems, as far as I can see. If a source file doesn't exist, then regular cp can handle that. If the target doesn't exist... well, users aren't allowed to write to /storage.)
I scan all of the arguments to see if they are existing files. If so, I see if they begin with "/storage". If they do, then I set a variable "link" to 1. After scanning the arguments, if link is equal to 1, then I use cp and add the symbolic link option -s. Otherwise, I go ahead with the copy.
Code:
#!/bin/sh
link=0
for arg in $@
do
if [ -a $arg ]
then
truePath=$(readlink -f "$arg")
if [ $(expr match "$truePath" "/storage") -gt 0 ]
then
link=1
fi
fi
done
if [ $link -eq 1 ]
then
cp -s $@
else
cp $@
fi
Thanks for your help. I'm putting this up in case anyone has a similar problem they want to tackle. Let me know if you see any issues with what I came up with.