0

To recreate the problem:

  1. Create an .bashrc_emacs file :
# -*- shell-script -*- export PATH="$PATH":~/SYNCHRO/bin/ # put the path to where net.ip.private is export BOOTTIME=$(sys.boottime) 
  1. Create and chmod +x the sys.boottime script:
 #!/bin/bash last reboot | awk 'NR == 1 {print $5,$6,$7,$8}' 
  1. Evaluate this line of elisp code:
 (setenv "BASH_ENV" (expand-file-name "~/.bashrc_emacs")) 

This should load the bashrc_emacs file prior to executing any shell command with M-!

  1. Then call any shell command, like a simple echo "hello world!"

In my case, it simply freezes. if I replace this line in the bashrc_emacs file:

export BOOTTIME=$(sys.boottime) 

with this line:

export UP=$(last reboot | awk 'NR == 1 {print $5,$6,$7,$8}') 

then everything works right.
it only freezes when I use that script,
which is in the path by the way.
you can even comment that line:

# export UP=$(last reboot | awk 'NR == 1 {print $5,$6,$7,$8}') # or # export BOOTTIME=$(sys.boottime) 

and M-! echo $BOOTTIME which should return last time your machine booted.

Any help appreciated.
This is Emacs 24 running on linux.

1 Answer 1

3
  • The file sys.boottime is a Bash script.
  • Bash will execute the file $BASH_ENV each time before it runs a script.
  • Command substitution $(sys.boottime) is put in the file $BASH_ENV.

There's an infinite recursion here, can you see that?

2
  • 1
    ... and read the bash man page (search for BASH_ENV - it's a big page) for some usage guidelines. @shynur's point can be summarized: don't ever execute a script inside the BASH_ENV script. You should only use it to set environment variables to constant values and that only if necessary - I have never ever used BASH_ENV and I've written a lot of bash code (even when I should have known better...) Commented Sep 12, 2024 at 3:26
  • Or, in this case, unset the BASH_ENV variable and then reset it. Commented Sep 13, 2024 at 8:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.