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

  • Home
  • SEARCH
  • 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 6732751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:41:15+00:00 2026-05-26T10:41:15+00:00

For example: Bash-Prog-Intro-HOWTO function foo() {} I make search queries in info bash and

  • 0

For example:
Bash-Prog-Intro-HOWTO

function foo() {}

I make search queries in info bash and look in releted chapters of POSIX for function keyword but nothing found.

What is function keyword used in some bash scripts? Is that some deprecated syntax?

  • 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-26T10:41:15+00:00Added an answer on May 26, 2026 at 10:41 am

    The function keyword is optional when defining a function in Bash, as documented in the manual:

    Functions are declared using this syntax:

    name () compound-command [ redirections ]

    or

    function name [()] compound-command [ redirections ]

    The first form of the syntax is generally preferred because it’s compatible with Bourne/Korn/POSIX scripts and so more portable.
    That said, sometimes you might want to use the function keyword to prevent Bash aliases from colliding with your function’s name. Consider this example:

    $ alias foo="echo hi"
    $ foo() { :; }
    bash: syntax error near unexpected token `('
    

    Here, 'foo' is replaced by the text of the alias of the same name because it’s the first word of the command. With function the alias is not expanded:

     $ function foo() { :; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: Bash 3.00 How to substitute this example string 123456789 , to look like
A contrived example... given FOO=/foo/bar/baz this works (in bash) BAR=$(basename $FOO) # result is
Is there a way to view a bash function's definition in bash? For example,
I need to pass a function as a parameter in Bash. For example, the
For example look at the following line of bash-code eval `echo ls *.jpg` It
Using bash, how can I search for all occurrences of the substring 'foo' in
Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$
I have a bash script mystuff containing a line like lynx -dump http://example.com >tmpfile
How do I truncate output in BASH? For example, if I du file.name how
I am trying to write a simple bash script that will search for files

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.