Why is bash echoing instead of running Apple Script
The problem are the single quotes in osascript -e '...'. Single quotes prevent variable expansion. This means that ${2} remains ${2} instead of being replaced with Spotify for example.

Try this:

function addtologin(){
    if [ $3 = "hidden" ]; then
        osascript -e "tell application \"System Events\" to make new login item with properties {path:\"${1}/${2}.app\", name:\"${2}\", hidden:true}"
    else
        osascript -e "tell application \"System Events\" to make new login item with properties {path:\"${1}/${2}.app\", name:\"${2}\", hidden:false}" 
    fi
}


Here we use double quotes which allow for expansion. To not confuse them with the inner quotes we need to escape those with \.

Now running the command with Spotify will output login item Spotify. This is just the result from the AppleScript, a login item was created. To suppress this you can add &gt;/dev/null to the command: osascript -e "tell ..." &gt;/dev/null.