# Should move shell module from sh to bash?

**URL:** <https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 8, 2014, 6:16am UTC](https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526 "2014-02-08T06:16:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![linbo\_liao](https://avatars.discourse-cdn.com/v4/letter/l/c67d28/32.png) [@linbo\_liao](https://forum.ansible.com/u/linbo_liao)\
**Post date:** [February 8, 2014, 6:16am UTC](https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526/1 "2014-02-08T06:16:27Z")

</div>

Hi,

Refer to [shell module doc](http://docs.ansible.com/shell_module.html), current it use /bin/sh to execute shell command, most time it works fine, but for following example, the result from Ubuntu is different.

- shell: command -v nwef

Since in Ubuntu, /bin/sh → dash, the command will return 127, not 1

```auto
$ cat test.sh
command -v nwef
echo $?

$ sh test.sh
127
$ ./test.sh
1
$ bash test.sh
1

```

I don’t know why dash return 127, it will cause result is not consistent in different platform.

If shell module move to bash, the result will be same in different Platform, and bash exist in most platform.

Thanks,  
Linbo

---

<div class="post-metadata">

**Author:** ![Brian\_Green](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@Brian\_Green](https://forum.ansible.com/u/Brian_Green)\
**Post date:** [February 8, 2014, 5:08pm UTC](https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526/2 "2014-02-08T17:08:40Z")

</div>

Unless I'm missing something, can't you just set executable: /bin/bash ?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [February 9, 2014, 12:51am UTC](https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526/3 "2014-02-09T00:51:39Z")

</div>

The /bin/sh can be very different shells on diff platforms, when linked to bash it is very forgiving about bashisms in posix sh, but other shells are not. If you are using bash shell syntax, point at bash, not sh, to avoid these errors.

---

<div class="post-metadata">

**Author:** ![linbo\_liao](https://avatars.discourse-cdn.com/v4/letter/l/c67d28/32.png) [@linbo\_liao](https://forum.ansible.com/u/linbo_liao)\
**Post date:** [February 10, 2014, 3:18am UTC](https://forum.ansible.com/t/should-move-shell-module-from-sh-to-bash/14526/4 "2014-02-10T03:18:00Z")

</div>

Sorry, I miss the executable params. Thanks for your reply.

在 2014年2月9日星期日UTC+8上午1时08分40秒，Brian Green写道：
