# In which shell Julia is running?

**URL:** <https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 11, 2023, 4:35pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814 "2023-01-11T16:35:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 11, 2023, 4:35pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/1 "2023-01-11T16:35:49Z")

</div>

I have Julia code that executes external commands with parameters. The parameters are file or folder names. I thought if I check if the code is executed on Windows and use a backslash as path delimiter on Windows and a slash otherwise it would work. But it does NOT work if Julia is executed in a bash shell (git bash) on Windows.

How can I determine if Julia is executed in bash, powershell or on the dos command prompt on Windows?

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [January 11, 2023, 4:46pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/2 "2023-01-11T16:46:32Z")

</div>

Try using `Base.Filesystem.joinpath`, or if you need to do it manually `Base.Filesystem.path_separator`, maybe that already does the right thing.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 11, 2023, 5:00pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/3 "2023-01-11T17:00:17Z")

</div>

I tried it, but it is not working correctly. On git bash on Windows I get:

```julia
Base.Filesystem.path_separator
"\\"

```

which is wrong and doesn’t work…

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [January 11, 2023, 5:07pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/4 "2023-01-11T17:07:41Z")

</div>

Huh, that’s annoying. How about checking the contents of `ENV["SHELL"]`?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 11, 2023, 5:25pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/5 "2023-01-11T17:25:55Z")

</div>

In git bash basename(ENV[“SHELL”]) is “bash.exe”. In powershell and on the command prompt this variable is undefined.

Not sure if I shall create a bug for Base.Filesystem.path\_separator …

---

<div class="post-metadata">

**Author:** ![piechologist](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piechologist/32/27662_2.png) [@piechologist](https://discourse.julialang.org/u/piechologist)\
**Post date:** [January 11, 2023, 5:53pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/6 "2023-01-11T17:53:03Z")

</div>

> [@ufechner7](#):
>
> `Base.Filesystem.path_separator`

I guess you _see_ two backslashes because the real and only one is masked. Try `Base.Filesystem.path_separator == '\\'` in the REPL.

According to the [documentation](https://docs.julialang.org/en/v1/manual/running-external-programs/):

- The command is never run with a shell. Instead, Julia parses the command syntax directly, appropriately interpolating variables and splitting on words as the shell would, respecting shell quoting syntax. The command is run as `julia`’s immediate child process, using `fork` and `exec` calls.

Do your paths contain spaces or maybe other problematic characters?

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [January 11, 2023, 7:43pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/7 "2023-01-11T19:43:08Z")

</div>

Remember, git-bash is running on Windows, and so your are using Windows Julia. Which bypasses the Posix-emulation library (cygwin.dll?) used by bash, and adresses Windows native API. So you get Windows path separator … because that will be what Julia will use to find the files.

If you want to use bash Unix-like file path inside Julia, you will have to split them with “/” and then join the part with the (Windows) system separator (see joinpath)

Hope it helps,

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 11, 2023, 7:47pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/8 "2023-01-11T19:47:05Z")

</div>

> [@jdad](#):
>
> If you want to use bash Unix-like file path inside Julia, you will have to split them with “/” and then join the part with the (Windows) system separator (see joinpath)

`/` works just fine on Windows too as long as you use it consistently (i.e. don’t try to mix it with backslash).

@ufechner7 didn’t provide any example of the code they are trying to run, but my suspicion is that the problem is more due to incorrect argument quoting in `run` or something rather than simple issues with `joinpath`.

In any, case, @ufechner7 really should provide a MWE; it’s pointless to speculate about hypothetical bugs.

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [January 11, 2023, 8:10pm UTC](https://discourse.julialang.org/t/in-which-shell-julia-is-running/92814/9 "2023-01-11T20:10:03Z")

</div>

BTW, I use `iscygwin()= Sys.iswindows() && haskey(ENV, "HOME")` to know if I am running under Cygwin. You could try a similar function for git-bash?
