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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:22:19+00:00 2026-05-25T01:22:19+00:00

I am trying to understand the cdargs-bash.sh script with cdargs packages. And I have

  • 0

I am trying to understand the “cdargs-bash.sh” script with cdargs packages. And I have a question about in the following function:

function _cdargs_get_dir ()
{
local bookmark extrapath
# if there is one exact match (possibly with extra path info after it),
# then just use that match without calling cdargs
if [ -e "$HOME/.cdargs" ]; then
    dir=`/bin/grep "^$1 " "$HOME/.cdargs"`
    if [ -z "$dir" ]; then
        bookmark="${1/\/*/}"
        if [ "$bookmark" != "$1" ]; then
            dir=`/bin/grep "^$bookmark " "$HOME/.cdargs"`
            extrapath=`echo "$1" | /bin/sed 's#^[^/]*/#/#'`
        fi
    fi
    [ -n "$dir" ] && dir=`echo "$dir" | /bin/sed 's/^[^ ]* //'`
fi
if [ -z "$dir" -o "$dir" != "${dir/
/}" ]; then
    # okay, we need cdargs to resolve this one.
    # note: intentionally retain any extra path to add back to selection.
    dir=
    if cdargs --noresolve "${1/\/*/}"; then
        dir=`cat "$HOME/.cdargsresult"`
        /bin/rm -f "$HOME/.cdargsresult";
    fi
fi
if [ -z "$dir" ]; then
    echo "Aborted: no directory selected" >&2
    return 1
fi
[ -n "$extrapath" ] && dir="$dir$extrapath"
if [ ! -d "$dir" ]; then
    echo "Failed: no such directory '$dir'" >&2
    return 2
fi

}

What’s the purpose of the testing:

"$dir" != "${dir/
/}"

Here the testing span over two lines; does it want to remove the newline character in $dir or maybe for some other reason? I am just starting to learn bash scripting and I have Googled some time but couldn’t find any usage like this.

  • 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-25T01:22:19+00:00Added an answer on May 25, 2026 at 1:22 am

    Yes you are right, it removes the newline character. I think the purpose of the test is to make sure $dir doesn’t contain multiple lines.

    Alternatively, you can remove \newline by

    ${dir/$'\n'/}
    

    This doesn’t require two lines so I think it looks better.

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

Sidebar

Related Questions

Trying to understand what Sql Profiler means by emitting sp_reset_connection. I have the following,
Just trying to understand that - I have never used it before. How is
Trying to understand why this doesn't work. I keep getting the following errors: left
Trying to understand resources in java-land. I believe the following is true: Resources loaded
Trying to understand a little more about Crockford's approach to Prototypical Inheritance whereby he
trying to understand how custom admin commands work, I have my project named mailing
Trying to understand how to link a function that is defined in a struct,
I trying to understand this piece of code Function.prototype.method = function (name, fn) {
HI Trying to understand how __radd__ works. I have the code >>> class X(object):
I trying to understand jquery, and can't figure a problem out. I have a

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.