I found a weird issue, getting different results with and without double quotes on a variable.
$ cat test.sh
#!/usr/bin/env bash
folder="~/backup"
ls -l ~/backup
ls -l ${folder}
$ bash test.sh
total 197904
-rw-r--r-- 1 test staff 96133120 31 Mar 22:46 backup-202103312246.tar.gz
ls: ~/backup: No such file or directory
If I remove the double quotes from the value of folder
$ cat test.sh
folder=~/backup
ls -l ~/backup
ls -l ${folder}
$ bash test.sh
total 197904
-rw-r--r-- 1 test staff 96133120 31 Mar 22:46 backup-202103312246.tar.gz
total 197904
-rw-r--r-- 1 test staff 96133120 31 Mar 22:46 backup-202103312246.tar.gz
Why do I get the different results?