• Abnormal HOME variable modification requirements.

    From hongyi.zhao@gmail.com@21:1/5 to All on Tue Oct 26 05:47:48 2021
    I've written the following Emacs package debug script which can be
    run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

    ```emacs-lisp
    #!/usr/bin/env bash
    :;# $ realpath init.el
    :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
    :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 /usr/local/bin/emacs -- "$@"; exit

    ;;Bootstrap straight
    (defvar bootstrap-version)
    (let ((bootstrap-file
    (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
    (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
    (with-current-buffer
    (url-retrieve-synchronously
    "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
    'silent 'inhibit-cookies)
    (goto-char (point-max))
    (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package company
    :demand t
    :hook
    (after-init . global-company-mode))
    ```
    But the `proxychains-ng-socks5` wrapper script relies on the normal HOME variable setting. How to solve this dilemma?

    Regards,
    HZ

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to hongy...@gmail.com on Tue Oct 26 13:55:27 2021
    On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:

    I've written the following Emacs package debug script which can be
    run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

    ```emacs-lisp
    #!/usr/bin/env bash
    :;# $ realpath init.el
    :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
    :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 /usr/local/bin/emacs -- "$@"; exit

    ;;Bootstrap straight
    (defvar bootstrap-version)
    (let ((bootstrap-file
    (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
    (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
    (with-current-buffer
    (url-retrieve-synchronously
    "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
    'silent 'inhibit-cookies)
    (goto-char (point-max))
    (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package company
    :demand t
    :hook
    (after-init . global-company-mode))
    ```
    But the `proxychains-ng-socks5` wrapper script relies on the normal HOME variable setting. How to solve this dilemma?

    Well, you /could/ derive your version of HOME differently. Yes, let's go
    with that.

    Initially, HOME is derived from the 6th field in the user's
    /etc/passwd entry. You could
    - use whoami(1) to determine the username
    - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
    and extract the home directory of the selected username
    - use that extracted home directory value to set your HOME variable

    HTH
    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Lew Pitcher on Tue Oct 26 08:14:02 2021
    On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
    On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:

    I've written the following Emacs package debug script which can be
    run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

    ```emacs-lisp
    #!/usr/bin/env bash
    :;# $ realpath init.el
    :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
    :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 /usr/local/bin/emacs -- "$@"; exit

    ;;Bootstrap straight
    (defvar bootstrap-version)
    (let ((bootstrap-file
    (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
    (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
    (with-current-buffer
    (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies)
    (goto-char (point-max))
    (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package company
    :demand t
    :hook
    (after-init . global-company-mode))
    ```
    But the `proxychains-ng-socks5` wrapper script relies on the normal HOME variable setting. How to solve this dilemma?
    Well, you /could/ derive your version of HOME differently. Yes, let's go
    with that.

    Initially, HOME is derived from the 6th field in the user's
    /etc/passwd entry. You could
    - use whoami(1) to determine the username
    - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
    and extract the home directory of the selected username
    - use that extracted home directory value to set your HOME variable

    Do you mean this one?

    $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
    /home/werner

    HZ

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Taylor@21:1/5 to hongy...@gmail.com on Tue Oct 26 10:04:37 2021
    On 10/26/21 6:47 AM, hongy...@gmail.com wrote:
    But the `proxychains-ng-socks5` wrapper script relies on the normal
    HOME variable setting. How to solve this dilemma?

    Please elaborate on what the abnormal HOME variable contents are?

    Are you artificially changing the HOME variable's contents at the start
    of the script? It looks like it's commented out to me. (But I don't
    speak LISP.)

    I'm failing to fathom a case where the contents of HOME would not be normal.



    --
    Grant. . . .
    unix || die

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to hongy...@gmail.com on Tue Oct 26 17:07:39 2021
    On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:

    On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
    On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:

    I've written the following Emacs package debug script which can be
    run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

    ```emacs-lisp
    #!/usr/bin/env bash
    :;# $ realpath init.el
    :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
    :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
    /usr/local/bin/emacs -- "$@"; exit

    ;;Bootstrap straight
    (defvar bootstrap-version)
    (let ((bootstrap-file
    (expand-file-name "straight/repos/straight.el/bootstrap.el"
    user-emacs-directory))
    (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
    (with-current-buffer
    (url-retrieve-synchronously
    "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
    'silent 'inhibit-cookies)
    (goto-char (point-max))
    (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package company
    :demand t
    :hook
    (after-init . global-company-mode))
    ```
    But the `proxychains-ng-socks5` wrapper script relies on the normal HOME >> > variable setting. How to solve this dilemma?
    Well, you /could/ derive your version of HOME differently. Yes, let's go
    with that.

    Initially, HOME is derived from the 6th field in the user's
    /etc/passwd entry. You could
    - use whoami(1) to determine the username
    - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
    and extract the home directory of the selected username
    - use that extracted home directory value to set your HOME variable

    Do you mean this one?

    $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
    /home/werner

    Sure. Or
    $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
    /home/lpitcher


    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to lew.pitcher@digitalfreehold.ca on Tue Oct 26 18:37:52 2021
    In article <sl9ckq$nc9$1@dont-email.me>,
    Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
    On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:

    On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
    On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:

    I've written the following Emacs package debug script which can be
    run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

    ```emacs-lisp
    #!/usr/bin/env bash
    :;# $ realpath init.el
    :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
    :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
    /usr/local/bin/emacs -- "$@"; exit

    ;;Bootstrap straight
    (defvar bootstrap-version)
    (let ((bootstrap-file
    (expand-file-name "straight/repos/straight.el/bootstrap.el"
    user-emacs-directory))
    (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
    (with-current-buffer
    (url-retrieve-synchronously
    "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
    'silent 'inhibit-cookies)
    (goto-char (point-max))
    (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package company
    :demand t
    :hook
    (after-init . global-company-mode))
    ```
    But the `proxychains-ng-socks5` wrapper script relies on the normal HOME >>> > variable setting. How to solve this dilemma?
    Well, you /could/ derive your version of HOME differently. Yes, let's go >>> with that.

    Initially, HOME is derived from the 6th field in the user's
    /etc/passwd entry. You could
    - use whoami(1) to determine the username
    - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd >>> and extract the home directory of the selected username
    - use that extracted home directory value to set your HOME variable

    Do you mean this one?

    $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
    /home/werner

    Sure. Or
    $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
    /home/lpitcher

    Or just:

    $ echo ~
    and
    $ echo ~lpitcher

    --
    People sleep peaceably in their beds at night only because rough
    men stand ready to do violence on their behalf.

    George Orwell

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Javier@21:1/5 to All on Tue Oct 26 18:26:27 2021
    Some software uses /etc/passwd instead of the HOME variable.
    It's a bug.

    Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
    fix the bug yourself.

    That bug was very common in the past. Fortunately nowadays most
    software has fixed it. Ivan Shmakov commented about that in
    comp.emacs a pair of years ago:

    Ivan Shmakov <ivan@siamics.net> on comp.emacs
    Message-ID: <8736wyx2p2.fsf_-_@violet.siamics.net>

    Unfortunately, some software refers to passwd(5) data directly
    instead, leaving no way for the user to override the home
    directory location. In particular, this was the behavior (IIRC)
    of programs based on older Glib versions. And I vaguely recall
    that Emacs might have been affected as well.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Javier on Tue Oct 26 17:39:19 2021
    On Wednesday, October 27, 2021 at 7:26:34 AM UTC+8, Javier wrote:
    Some software uses /etc/passwd instead of the HOME variable.
    It's a bug.

    Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
    fix the bug yourself.

    That bug was very common in the past. Fortunately nowadays most
    software has fixed it. Ivan Shmakov commented about that in
    comp.emacs a pair of years ago:

    Ivan Shmakov <iv...@siamics.net> on comp.emacs
    Message-ID: <8736wyx2...@violet.siamics.net>

    Unfortunately, some software refers to passwd(5) data directly
    instead, leaving no way for the user to override the home
    directory location. In particular, this was the behavior (IIRC)
    of programs based on older Glib versions. And I vaguely recall
    that Emacs might have been affected as well.

    Thank you for much for your explanation. This is just the case of my dilemma.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Lew Pitcher on Wed Oct 27 10:19:22 2021
    Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
    On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
    [...]
    If $HOME is not reliably set, then ~ is unlikely to be either.
    Witness:

    10:27 $ echo $HOME
    /home/lpitcher
    10:27 $ echo ~
    /home/lpitcher

    Both $HOME and ~ point at my home directory

    But now, I change $HOME to point somewhere else
    10:27 $ HOME=/var/some/directory
    10:28 $ echo $HOME
    /var/some/directory

    And, lo and behold, ~ changes as well
    10:28 $ echo ~
    /var/some/directory

    So, if the OP can't depend on $HOME to point to the proper
    directory (hence, his asking how to derive the home directory)
    then he can't depend on ~ either.

    HTH

    FWIW, from bash(1):
    Shell Variables
    The following variables are set by the shell:
    ...
    HOME The home directory of the current user; the default argument for
    the cd builtin command. The value of this variable is also used
    when performing tilde expansion.

    On the other hand, ~username, as opposed to just ~, does not depend on
    $HOME. It does a lookup in /etc/passwd or whatever the system's
    equivalent is.

    $ echo $HOME ~ ~kst
    /home/kst /home/kst /home/kst
    $ HOME=/tmp
    $ echo $HOME ~ ~kst
    /tmp /tmp /home/kst
    $ eval echo ~$USER
    /home/kst
    $ eval echo ~$(whoami)
    /home/kst
    $

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    Working, but not speaking, for Philips
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Keith Thompson on Wed Oct 27 18:10:47 2021
    On Wed, 27 Oct 2021 10:19:22 -0700, Keith Thompson wrote:

    Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
    On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
    [...]
    If $HOME is not reliably set, then ~ is unlikely to be either.
    Witness:

    10:27 $ echo $HOME
    /home/lpitcher
    10:27 $ echo ~
    /home/lpitcher

    Both $HOME and ~ point at my home directory

    But now, I change $HOME to point somewhere else
    10:27 $ HOME=/var/some/directory
    10:28 $ echo $HOME
    /var/some/directory

    And, lo and behold, ~ changes as well
    10:28 $ echo ~
    /var/some/directory

    So, if the OP can't depend on $HOME to point to the proper
    directory (hence, his asking how to derive the home directory)
    then he can't depend on ~ either.

    HTH

    FWIW, from bash(1):
    Shell Variables
    The following variables are set by the shell:
    ...
    HOME The home directory of the current user; the default argument for
    the cd builtin command. The value of this variable is also used
    when performing tilde expansion.

    On the other hand, ~username, as opposed to just ~, does not depend on
    $HOME. It does a lookup in /etc/passwd or whatever the system's
    equivalent is.

    $ echo $HOME ~ ~kst
    /home/kst /home/kst /home/kst
    $ HOME=/tmp
    $ echo $HOME ~ ~kst
    /tmp /tmp /home/kst
    $ eval echo ~$USER
    /home/kst
    $ eval echo ~$(whoami)
    /home/kst
    $

    Thanks, Keith

    I'm glad to have learned something new today.

    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Lew Pitcher on Thu Oct 28 01:07:17 2021
    On Thursday, October 28, 2021 at 2:10:52 AM UTC+8, Lew Pitcher wrote:
    On Wed, 27 Oct 2021 10:19:22 -0700, Keith Thompson wrote:

    Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
    On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
    [...]
    If $HOME is not reliably set, then ~ is unlikely to be either.
    Witness:

    10:27 $ echo $HOME
    /home/lpitcher
    10:27 $ echo ~
    /home/lpitcher

    Both $HOME and ~ point at my home directory

    But now, I change $HOME to point somewhere else
    10:27 $ HOME=/var/some/directory
    10:28 $ echo $HOME
    /var/some/directory

    And, lo and behold, ~ changes as well
    10:28 $ echo ~
    /var/some/directory

    So, if the OP can't depend on $HOME to point to the proper
    directory (hence, his asking how to derive the home directory)
    then he can't depend on ~ either.

    HTH

    FWIW, from bash(1):
    Shell Variables
    The following variables are set by the shell:
    ...
    HOME The home directory of the current user; the default argument for
    the cd builtin command. The value of this variable is also used
    when performing tilde expansion.

    On the other hand, ~username, as opposed to just ~, does not depend on $HOME. It does a lookup in /etc/passwd or whatever the system's
    equivalent is.

    $ echo $HOME ~ ~kst
    /home/kst /home/kst /home/kst
    $ HOME=/tmp
    $ echo $HOME ~ ~kst
    /tmp /tmp /home/kst
    $ eval echo ~$USER
    /home/kst
    $ eval echo ~$(whoami)
    /home/kst
    $
    Thanks, Keith

    I'm glad to have learned something new today.

    Me too; so am I; So do I.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Keith Thompson on Thu Oct 28 01:23:39 2021
    On Thursday, October 28, 2021 at 1:19:27 AM UTC+8, Keith Thompson wrote:
    Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
    On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
    [...]
    If $HOME is not reliably set, then ~ is unlikely to be either.
    Witness:

    10:27 $ echo $HOME
    /home/lpitcher
    10:27 $ echo ~
    /home/lpitcher

    Both $HOME and ~ point at my home directory

    But now, I change $HOME to point somewhere else
    10:27 $ HOME=/var/some/directory
    10:28 $ echo $HOME
    /var/some/directory

    And, lo and behold, ~ changes as well
    10:28 $ echo ~
    /var/some/directory

    So, if the OP can't depend on $HOME to point to the proper
    directory (hence, his asking how to derive the home directory)
    then he can't depend on ~ either.

    HTH

    FWIW, from bash(1):
    Shell Variables
    The following variables are set by the shell:
    ...
    HOME The home directory of the current user; the default argument for
    the cd builtin command. The value of this variable is also used
    when performing tilde expansion.
    On the other hand, ~username, as opposed to just ~, does not depend on
    $HOME. It does a lookup in /etc/passwd or whatever the system's
    equivalent is.

    $ echo $HOME ~ ~kst
    /home/kst /home/kst /home/kst
    $ HOME=/tmp
    $ echo $HOME ~ ~kst
    /tmp /tmp /home/kst
    $ eval echo ~$USER
    /home/kst


    $ eval echo ~$(whoami)
    /home/kst
    $

    Some supplement

    werner@X10DAi-00:~$ echo $(eval echo ~$USER)
    /home/werner
    werner@X10DAi-00:~$ echo $(eval echo ~$USERNAME)
    /home/werner
    werner@X10DAi-00:~$ echo $(eval echo ~$(whoami))
    /home/werner

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)