### Bug description

I am currently maintaining a set of homebrew formulae (for MacOS) for both quarto and quarto-dev, a user just reported (rundel/homebrew-quarto-cli#37) that as of v1.1.113 they are getting an error when running quarto installed using this formula. Specifically,
```
> quarto preview
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]
ERROR: Cannot determine the Quarto source path. This script must be run from the bin or common folder.
```
this is still occurring with the latest pre-release (v1.1.119).

These formulae are installing the files from the `quarto-1.1.119-macos.tar.gz` assest into a homebrew cellar which are then symlinked into `/opt/homebrew`. The issue appears to be with how the primary quarto shell script is handling the construction of [`SCRIPT_PATH`](https://github.com/quarto-dev/quarto-cli/blob/1fbd4124cc00101f19601adbccd3ccc3474f6e1e/package/scripts/common/quarto#L4-L13) when the symlink is a relative path.

```
> ls -la /opt/homebrew/bin/quarto                                                                                                             
lrwxr-xr-x  1 rundel  admin  39 Aug 24 17:54 /opt/homebrew/bin/quarto -> ../Cellar/quarto-dev/1.1.119/bin/quarto
```

For this case it appears that https://github.com/quarto-dev/quarto-cli/blob/1fbd4124cc00101f19601adbccd3ccc3474f6e1e/package/scripts/common/quarto#L8
does not work as a relative path is not handled properly by `cd` since this is relative to where the script was invoked and not where the script lives.

The breaking changes seem to be part of #2015.




### Checklist

- [X] upgraded to the [latest nightly quarto version](https://github.com/quarto-dev/quarto-cli/releases)?
- [X] [formatted your issue](https://yihui.org/issue/#please-format-your-issue-correctly) so it is easier for us to read?
- [X] included a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] documented which operating system you're running? If on Linux, please provide the specific distribution as well.
2022-08-25T00:03:55Z
rundel
bug
closed
SCRIPT_PATH discovery is broken for relative symlinks 
https://github.com/quarto-dev/quarto-cli/issues/2113