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 8447085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:05:55+00:00 2026-06-10T10:05:55+00:00

Is the return value of a bash function the status of the last executed

  • 0

Is the return value of a bash function the status of the last executed command?

I wrote this test and it looks like it’s so. I just want to verify. No one has asked this question before apparently and tutorials don’t mention this.

Test program:

funa() {
  echo "in funa";
  true;
};

funb() {
  echo "in funb"
  false;
};

funa && echo "funa is true";    
funb && echo "funb is true";

Output when I run the program:

in funa
funa is true
in funb

Does anyone know the answer?

  • 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-06-10T10:05:57+00:00Added an answer on June 10, 2026 at 10:05 am

    Yes. Per man bash:

    Shell Function Definitions

    When executed, the exit status of
    a function is the exit status of the last command executed in
    the body. (See FUNCTIONS below.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to test a Bash function's return value in an if statement
Possible Duplicate: Return value from thread I want to get the free memory of
I want to access java script's return value , which in is in a
Is it possible to get the 'nth' return value from a function without having
Possible Duplicate: Access return value from Thread.Start()'s delegate function public string sayHello(string name) {
How to get return value from mouse capturing function? function getMousePosition(e) { positionX =
I understand if I write a bash script I can get the return value,
Is it possible to have an awk command within a bash script return values
I'm not able to check the return values of the function test; man test
In my program I am trying to return a value from a function, the

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.