You are not logged in.

#1 2024-02-25 23:09:26

waffle0007
Member
From: USA
Registered: 2021-08-14
Posts: 20

Bash not recognising built-in shell commands

When running a script containing

#!/usr/bin/env bash
which foo
$ ./test.sh
./test.sh: line 2: which: command not found

The same happens with various interpreter variations

#!/bin/bash
#!/usr/bin/bash
#!/bin/sh
# etc.

However, 'zsh' does work, for what it's worth. Please let me know if I can provide any additional information.

Offline

#2 2024-02-25 23:41:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,269

Re: Bash not recognising built-in shell commands

which is a program and a package not a built-in. Is your PATH broken? Are you using lightdm? It recently had an adjustment of it's session handling when using different shells and that caused some issues. echo your $PATH in one of the failing scripts.

Offline

#3 2024-02-25 23:42:30

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,579
Website

Re: Bash not recognising built-in shell commands

What makes you think that 'which' is a bash builtin?

bash$ type which
which is /usr/bin/which

If your script doesn't set PATH, call the binary by it's absolute path.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2024-02-26 08:57:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,569

Online

Board footer

Powered by FluxBB