Skip to main content
deleted 89 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

Newbie here. I'm reading a shell script for adding a progress bar to certain processes (found here). I'm having trouble understanding this (optional) line:

#BAR_EXT=${BAR_EXT-}

The comment says that this will add an extension to each file, and maybe I just need to read further, but I'm not familiar with that use of the - operator.

I know about this kind of substitution, as found in the Bash Reference Manual:

${parameter:-word}

I also know that the above will replace a null value for parameter with word, whereas ${parameter-word} will not. (At least, I think I know that.)

But with nothing specified after the - here, I'm not sure what's going on. Will this simply replace parameter with a null value? Generally, I would accept that as a working guess and just keep reading, but with the comment mentioning adding extensions to files, I'm confused.

Maybe a stupid question, but my Google-fu is weak on this one.

Newbie here. I'm reading a shell script for adding a progress bar to certain processes (found here). I'm having trouble understanding this (optional) line:

#BAR_EXT=${BAR_EXT-}

The comment says that this will add an extension to each file, and maybe I just need to read further, but I'm not familiar with that use of the - operator.

I know about this kind of substitution, as found in the Bash Reference Manual:

${parameter:-word}

I also know that the above will replace a null value for parameter with word, whereas ${parameter-word} will not. (At least, I think I know that.)

But with nothing specified after the - here, I'm not sure what's going on. Will this simply replace parameter with a null value? Generally, I would accept that as a working guess and just keep reading, but with the comment mentioning adding extensions to files, I'm confused.

Maybe a stupid question, but my Google-fu is weak on this one.

I'm reading a shell script for adding a progress bar to certain processes (found here). I'm having trouble understanding this (optional) line:

#BAR_EXT=${BAR_EXT-}

The comment says that this will add an extension to each file, and maybe I just need to read further, but I'm not familiar with that use of the - operator.

I know about this kind of substitution, as found in the Bash Reference Manual:

${parameter:-word}

I also know that the above will replace a null value for parameter with word, whereas ${parameter-word} will not. (At least, I think I know that.)

But with nothing specified after the - here, I'm not sure what's going on. Will this simply replace parameter with a null value? Generally, I would accept that as a working guess and just keep reading, but with the comment mentioning adding extensions to files.

Source Link
wubzy
  • 33
  • 2

Bourne shell: trailing `-` operator in parameter substitution

Newbie here. I'm reading a shell script for adding a progress bar to certain processes (found here). I'm having trouble understanding this (optional) line:

#BAR_EXT=${BAR_EXT-}

The comment says that this will add an extension to each file, and maybe I just need to read further, but I'm not familiar with that use of the - operator.

I know about this kind of substitution, as found in the Bash Reference Manual:

${parameter:-word}

I also know that the above will replace a null value for parameter with word, whereas ${parameter-word} will not. (At least, I think I know that.)

But with nothing specified after the - here, I'm not sure what's going on. Will this simply replace parameter with a null value? Generally, I would accept that as a working guess and just keep reading, but with the comment mentioning adding extensions to files, I'm confused.

Maybe a stupid question, but my Google-fu is weak on this one.