When I run `sudo echo "$HOME"` in an interactive shell, it prints my own home directory. If I write a shell script containing `echo "$HOME"` and then run the script with sudo, it prints the home for root (`/root`). This is confusing behavior.
I'm using sudo 1.8.18p1 on Fedora 25 Workstation x86_64. I've tried this with both fish 2.3.1 and bash 4.3.43(1)-release in GNOME Terminal 3.22.1. I have only modified the sudoers config a little:
$ sudo cat /etc/sudoers.d/00_custom
Defaults env_keep += "EDITOR VISUAL"
Defaults env_keep += "PAGER LESS MANOPT"
Defaults env_keep += "XZ_DEFAULTS"
Defaults secure_path = /home/terrycloth/apps:/home/terrycloth/bin:/home/terrycloth/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
Interestingly, "$USER" stays the same (my username) on both the CLI and in scripts.
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora 'version'
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.
Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
Thank you for reporting this bug and we are sorry it could not be fixed.