Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6382927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:35:09+00:00 2026-05-25T02:35:09+00:00

Suppose I write a function in a bash script, with the name of an

  • 0

Suppose I write a function in a bash script, with the name of an available binary, say, pwd:

function pwd(){
    echo '/'
}

Alright, that seems a bit weird, but the question is: what will happen if further in my script I write the commands:

cd /usr
pwd

What pwd will be used? Also, how can I force the use of the other one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:35:10+00:00Added an answer on May 25, 2026 at 2:35 am

    Your function will get called because it hides the pwd builtin.

    To force the command to be executed, use the command builtin:

    command pwd
    

    From bash manual:

       command [-pVv] command [arg ...]
              Run command with args  suppressing  the  normal  shell  function
              lookup.  Only builtin commands or commands found in the PATH are
              executed.  If the -p option is given, the search for command  is
              performed  using  a default value for PATH that is guaranteed to
              find all of the standard utilities.  If  either  the  -V  or  -v
              option is supplied, a description of command is printed.  The -v
              option causes a single word indicating the command or file  name
              used to invoke command to be displayed; the -V option produces a
              more verbose description.  If the -V or -v option  is  supplied,
              the  exit  status  is  0 if command was found, and 1 if not.  If
              neither option is supplied and an error occurred or command can-
              not  be found, the exit status is 127.  Otherwise, the exit sta-
              tus of the command builtin is the exit status of command.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you write a function in SQL Server that conditionally calls itself. If you
My question is with regard to C++ Suppose I write a function to return
I'm trying to write a function that needs to know the property names of
Is there a way to write the PHP file_exists function so that it searches
I want to write a python function decorator that tests that certain arguments to
Suppose I want to write a function in R which is a function of
Please suppose I have a function that accepts a pointer as a parameter. This
Suppose I have a function f that takes a vector v and returns a
Suppose I write a black-box functions, which evaluates an expensive complex valued function numerically,
Suppose I want to write a function like the following (as usual, a trivial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.