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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:44:59+00:00 2026-05-31T02:44:59+00:00

I see the – operator behaving in different ways with different commands. For example,

  • 0

I see the - operator behaving in different ways with different commands.

For example,

cd - 

cds to the previous directory, whereas,

vim -

reads from stdin

So I want to know why the - operator is behaving in 2 different ways here. Can someone point me to some detailed documentation of the - operator?

  • 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-31T02:45:00+00:00Added an answer on May 31, 2026 at 2:45 am

    It is not an operator, it is an argument. When you write a program in C or C++ it comes as argv[1] (when it is the first argument) and you can do whatever you like with it.

    By convention, many programs use - as a placeholder for stdin where an input file name is normally required, and stdout where an output file name is expected. But cd does not require reading a file stream, why should it need stdin or stdout?

    Extra: here below is the excerpt from vim’s main.c that parses arguments that begin with -: if there is no additional character it activates STDIN input.

        else if (argv[0][0] == '-' && !had_minmin)
        {
            want_argument = FALSE;
            c = argv[0][argv_idx++];
    #ifdef VMS
            ...
    #endif
            switch (c)
            {
            case NUL:       /* "vim -"  read from stdin */
                    /* "ex -" silent mode */
            if (exmode_active)
                silent_mode = TRUE;
            else
            {
                if (parmp->edit_type != EDIT_NONE)
                mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
                parmp->edit_type = EDIT_STDIN;
                read_cmd_fd = 2;    /* read from stderr instead of stdin */
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See the gray bar in this example page: http://dss.com.bo/inicio.aspx Here is my attempt at
see the example first then you can understand my question. var x; function checkTime()
See subject. What were they thinking? UPDATE: Changed from static to internal linkage to
See edit at the end I am trying to overload the + operator in
See working example at http://jsfiddle.net/xqwqH . I have a green div inside a red
See this example: echo memory_get_usage() . \n; // 36640 $a = str_repeat(Hello, 4242); echo
(see jsfiddle example) When the .link_to_rule_them_all is clicked i would like to copy all
See the iPhone page for an example of what I'm talking about. Apple positions
See this jsfiddle for example: http://jsfiddle.net/FrJRA/1/ and note that the inner span's border overlaps
See my example code below <script> alert(a); // undefined alert(b); // It is Error,

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.