user15760077
user15760077

Reputation:

Why does `ps -p $PPID -o comm=` return different result?

I use the following code to detect the current interactive shell

#!/usr/bin/env bash
ps -p $PPID -o comm=

On macOS, returns -zsh On Debian returns zsh On centOS, returns zsh

Why is there a - symbol? Thank you.

Upvotes: 1

Views: 156

Answers (1)

Gene
Gene

Reputation: 46970

As the Bash manual says, ...

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

Most likely your Mac is giving you a login shell, and the others are subshells.

Upvotes: 2

Related Questions