Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

${} translation

31 views
Skip to first unread message

ruben safir

unread,
Dec 13, 2017, 8:08:36 PM12/13/17
to
_pkgname=${pkgname%-*}

What exactly does this do?

It comes from this uri
https://wiki.archlinux.org/index.php/Dynamic_Kernel_Module_Support#PKGBUILD

Lew Pitcher

unread,
Dec 13, 2017, 8:43:28 PM12/13/17
to
ruben safir wrote:

> _pkgname=${pkgname%-*}
>
> What exactly does this do?

It sets parameter $_pkgname with a value derived from the parameter $pkgname

The shell will expand ${pkgname%-*} into a string containing all the
characters from the expansion of $pkgname stopping at (and not including)
the rightmost hyphen and any characters that follow it.

For example, if
$pkgname
expands to "abc-def-ghi" then
${pkgname%-*}
expands to "abc-def"

[snip]

--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

Thomas 'PointedEars' Lahn

unread,
Dec 13, 2017, 11:18:47 PM12/13/17
to
RTFM.

--
PointedEars

Twitter: @PointedEars2
Please do not cc me. /Bitte keine Kopien per E-Mail.

Barry Margolin

unread,
Dec 13, 2017, 11:28:43 PM12/13/17
to
In article <p0siue$br8$1...@reader2.panix.com>,
Read the "Parameter Expansion" section of the Bash manual to see the
meaning of all the variations on ${variable}

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Tobiah

unread,
Jan 4, 2018, 5:35:06 PM1/4/18
to
On 12/13/2017 08:18 PM, Thomas 'PointedEars' Lahn wrote:
> ruben safir wrote:
>
>> _pkgname=${pkgname%-*}
>>
>> What exactly does this do?
>>
>> It comes from this uri
>>
> https://wiki.archlinux.org/index.php/Dynamic_Kernel_Module_Support#PKGBUILD
>
> RTFM.
>

I don't have any problem with questions that could be
answered by reading the very long (and often difficult to search)
bash man page. The straight answer would make better reading
for me, although I did enjoy your insight here.

Thomas 'PointedEars' Lahn

unread,
Jan 4, 2018, 6:18:45 PM1/4/18
to
Nobody cares.

David W. Hodgins

unread,
Jan 4, 2018, 7:10:48 PM1/4/18
to
On Thu, 04 Jan 2018 17:34:59 -0500, Tobiah <to...@tobiah.org> wrote:

> On 12/13/2017 08:18 PM, Thomas 'PointedEars' Lahn wrote:
>> ruben safir wrote:
>>> _pkgname=${pkgname%-*}
>>> What exactly does this do?

Quickest way to find out is to try it ...

[dave@x3 ~]$ pkgname="xxx-yyy-zzz"
[dave@x3 ~]$ echo ${pkgname%-*}
xxx-yyy

So in this case it strips the last matching string ("-" in this case)
and everything after it.

Regards, Dave Hodgins

--
Change dwho...@nomail.afraid.org to davidw...@teksavvy.com for
email replies.
0 new messages