You're not limited to single line Applescript code. Here we take the previous two examples and combine them into a single function.
#!/bin/bash
pageinfo() {
osascript -e \
'tell app "safari"
tell the current tab of window 1
return {url & "\n" & name}
end tell
end tell'
}