dash: 1: [[: not found
and similar with ash
shells.bash
's [[
while it's being run with POSIX based shells. But couldn't figure out which one.strace
to find out all the files being read. The result surprised me - none of the profile based files were listed in the strace output.$ strace -fe trace=%file bash -c exit
execve("/usr/bin/bash", ["bash", "-c", "exit"], 0x7ffc430c3870 /* 67 vars */) = 0
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libtinfo.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/dev/tty", O_RDWR|O_NONBLOCK) = 3
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY) = 3
stat("/home/user", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/user", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/user/.cargo/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.local/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.local/opt/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.cargo/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.npm/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.cargo/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.local/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.local/opt/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.cargo/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/.npm/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/home/user/workspace/go/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/usr/local/sbin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
access("/usr/bin/bash", X_OK) = 0
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
access("/usr/bin/bash", R_OK) = 0
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
access("/usr/bin/bash", X_OK) = 0
stat("/usr/bin/bash", {st_mode=S_IFREG|0755, st_size=1166912, ...}) = 0
access("/usr/bin/bash", R_OK) = 0
+++ exited with 0 +++
Running with plain strace -f bash |& grep profile
and such also seem to show nothing.
.profile
, /etc/profile
, /etc/bashrc
.bashrc
etc?ENOENT
s happen here - stat("/home/user/.cargo/bin/bash", 0x7ffe62a61e90) = -1 ENOENT (No such file or directory)
- It appears it's searching for bash on all the env paths. But why does this happen? (How to find what is actually executing the bash
command here which results in the PATH search)You are seeing all the files that the shell is reading.
/etc/profile
, ~/.profile
, ~/.bash_profile
and ~/.bash_login
are login files that bash only reads if it's invoked as a login shell. /etc/bashrc
(or /etc/bash.bashrc
) and ~/.bashrc
are customization files for interactive sessions (with quirks that aren't relevant here). None of these files are read when interpreting a script or running a single command with -c
.
Bash does read the file whose name is in the BASH_ENV
environment variable when it starts. But normally this environment variable is unset so bash doesn't read any file.
Bash apparently likes to obtain information about its own binary when it starts. I don't know what that's for, but it's built-in behavior, not behavior that comes from some startup script.
None of this will help you in any way to understand why a script that contains bash constructs is being run with dash. The reason the script is run with dash is probably that /bin/sh
is dash on your system: systems rarely invoke dash
explicitly. If you don't know which script is causing this or if you don't understand how that script is called, your investigation should to start from the circumstances under which the message appears. If it's a login-time script, you need to understand how login works on your system and what programs are invoked. Unix & Linux may help with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With