GithubHelp home page GithubHelp logo

Comments (4)

korcankaraokcu avatar korcankaraokcu commented on June 4, 2024 1

There goes another easter egg...

whoami is included in coreutils, it's a good replacement

from pince.

brkzlr avatar brkzlr commented on June 4, 2024

It's not intentional. Looks like the common "who am i" or "who mom likes" commands are returning empty for some terminals. On our tested terminals it works correctly.

Might be a problem as some terminals do not correctly return some info needed by who when the 2 random arguments are supplied (effectively converting it to who -m).

@korcankaraokcu We can just remove the "mom likes" easter egg (sadly) and that should fix it for all terminals.

from pince.

salihmarangoz avatar salihmarangoz commented on June 4, 2024

I am using GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu). Also, I wouldn't recommend using who to detect the current user. For example, I have a multi-head system where two people are using the same system but the output of who is the same for both users. In this case, the first line doesn't represent the current user, because when user2 run who command the output will look like this:

user1    :2           2023-06-03 02:34 (:2)
user2    :0           2023-06-03 02:34 (:0)

Alternatively using id -un may be better... Maybe...

CURRENT_USER="$(whoami)"
# or...
CURRENT_USER="$(id -un)"

from pince.

brkzlr avatar brkzlr commented on June 4, 2024

'who' was most likely chosen because 'whoami' is affected by sudo and other effective user id changing tools, which would mess up the permissions set by the script.

I guess we can change now to 'whoami' since we recently introduced safeguards against sudo running.

from pince.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.