Differences between revisions 6 and 27 (spanning 21 versions)
Revision 6 as of 2007-10-10 20:40:20
Size: 11362
Editor: 193
Comment:
Revision 27 as of 2015-06-19 01:21:19
Size: 11432
Editor: koala_man
Comment: Spam
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
The X-Y Problem, as it is sometimes called, is a logical fallacy which leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. It often goes something like this: The X-Y Problem, as it is sometimes called, is a mental block which leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. It often goes something like this:
Line 8: Line 8:
 * After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable substitute for X.  * After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable solution for X.

The problem occurs when people get their train of thought stuck on one approach and become unable to take a step back. Remaining open to having a new look at the bigger picture, these people might find their way back to X and continue searching for alternative solutions.
Line 12: Line 14:
<n00b> How can I echo the last three characters in a filename?

<feline> If they're in a variable: echo ${foo: -3}
<feline> Why 3 characters? What do you REALLY want?
<feline> Do you want the extension?

<n00b> Yes.

<feline> Then ASK FOR WHAT YOU WANT!
<feline> There's no guarantee that every filename will have a three-letter extension,
<feline> so blindly grabbing three characters does not solve the problem.
<feline> echo ${foo##*.}
<n00b> How can I echo the last three characters in a filename?

<feline> If they're in a variable: echo ${foo: -3}
<feline> Why 3 characters? What do you REALLY want?
<feline> Do you want the extension?

<n00b> Yes.

<feline> Then ASK FOR WHAT YOU WANT!
<feline> There's no guarantee that every filename will have a three-letter extension,
<feline> so blindly grabbing three characters does not solve the problem.
<feline> echo ${foo##*.}
Line 28: Line 30:
&lt;lhunath&gt; when starting a process from shell, the process inherits the gid of the shell - I'm looking to start a process with a different GID than my own, so I assumed I should first newgrp to the new group and then start the process - however, newgrp audio gives the following error when run as non-root: Cannot execute bash: No such file or directory
&lt;lhunath&gt; newgrp - audio works, however, but I can't use this in a shell script to start a certain process with a different GID since it spawns a subshell

&lt;greycat&gt; What are you *really* trying to do?

&lt;lhunath&gt; trying to start wine with GID of audio

&lt;greycat&gt; lhunath: well... daemontools includes a setuidgid program that could do it, but to run that, you have to start out as root, and then define a user account whose primary group has the GID you desire.
&lt;greycat&gt; I suspect what you *Really* want to do is "make wine's audio work". Which means you probably want to add yourself to group 'audio' in /etc/group, and logout and back in.

&lt;lhunath&gt; grin, if only it were that easy. no, what I'm *really* trying to do is to get the rlimits that I set in pam for @audio to apply to the wineserver process so that it can use the sched_fifo to give audio threads a higher priority for games that request it. for wineserver to be able to use the rlimits, it needs to have a gid of the @audio that I defined in /etc/security/limits.conf

&lt;greycat&gt; You don't actually think that rlimits magically "pop up" when a process is invoked with a specific UID/GID, do you?
&lt;greycat&gt; rlimits are set within your *own* process and then handed down to your children when you fork/exec thme.
&lt;greycat&gt; Only specific things read pam.d config files -- things that are linked with libpam.
&lt;greycat&gt; Like /bin/login or /usr/sbin/sshd.

&lt;lhunath&gt; greycat: should if I define '@audio - rtprio 90' in /etc/security/limits.conf ;x

&lt;greycat&gt; lhunath: what process do you think reads that file?

&lt;lhunath&gt; pam
&lt;lhunath&gt; hrm.

&lt;greycat&gt; lhunath: and you think that "wine" is linked with libpam?
&lt;greycat&gt; you need to set the limits you want, *and then* run the program you want.
&lt;greycat&gt; it will inherit them.
&lt;greycat&gt; I do stuff like this all the time: su --&gt; ulimit -v whatever --&gt; su - freenet --&gt; start the Freenet node
&lt;greycat&gt; usually exec su - freenet, so that a raw root shell isn't left lying about if/when the freenet processes terminate

&lt;lhunath&gt; heh.

&lt;goldfish&gt; nice

&lt;greycat&gt; See, *this* is why I ask things like "What are you really trying to do"
RikusW> Say I have a filename in $1 how would I get its size ?

greycat> Why?

erUSUL> du $file

RikusW> ty

erUSUL> du "$file" even

RikusW> havent thought of that ... :)

greycat> Literal answers to bad questions can be dangerous.
greycat> WHY do you want its size? What is the POINT?

RikusW> `du $1` maybe ?
RikusW> Want to write a script to dd 512k sections out and md5sum it...

erUSUL> RikusW: huh? you want to do something with the size later?

greycat> you want to WHAT?

RikusW> dd doesn't return 1 when the end is reached...

greycat> ... why wouldn't you take a SINGLE md5 of the whole thing?

RikusW> I have a corrupt 500mb file....
RikusW> and a slow connection

greycat> rsync.
greycat> NEXT!
Line 65: Line 63:
This one happens a lot. Seriously, we see something like this at ''least'' once a week:
Another example:
Line 68: Line 65:
&lt;chron&gt; i'm editting a sed stream like: sed 's/^/blah/'
&lt;chron&gt; but i want to replace with 'blah/' instead of 'blah'
&lt;chron&gt; editting a stream*

&lt;greycat&gt; blah\/ or use a different separator

&lt;_matt&gt; blah\//

&lt;chron&gt; thanks
&lt;chron&gt; i'm trying to ls a directory, and every file or folder that shows in ls, i want it to come out like file1 file2 file3 (all in one line)
&lt;chron&gt; instead of columns or list

&lt;greycat&gt; echo *

&lt;trash&gt; chron: echo dir/*

&lt;chron&gt; i'm trying to compare 2 files: file1 and file2, if there is any matching line in file1 from file2, i want it gone from file1

&lt;greycat&gt; !faq subtract
-&gt;#bash http://wooledge.org/mywiki/BashFaq#faq36 -- How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction).

&lt;trash&gt; !bashphorism2
-&gt;#bash The questioner will keep changing the original question until it drives the helpers in the channel insane.
<lhunath> when starting a process from shell, the process inherits the gid of the shell - I'm looking to start a process with a different GID than my own, so I assumed I should first newgrp to the new group and then start the process - however, newgrp audio gives the following error when run as non-root: Cannot execute bash: No such file or directory
<lhunath> newgrp - audio works, however, but I can't use this in a shell script to start a certain process with a different GID since it spawns a subshell

<greycat> What are you *really* trying to do?

<lhunath> trying to start wine with GID of audio

<greycat> lhunath: well... daemontools includes a setuidgid program that could do it, but to run that, you have to start out as root, and then define a user account whose primary group has the GID you desire.
<greycat> I suspect what you *Really* want to do is "make wine's audio work". Which means you probably want to add yourself to group 'audio' in /etc/group, and logout and back in.

<lhunath> grin, if only it were that easy. no, what I'm *really* trying to do is to get the rlimits that I set in pam for @audio to apply to the wineserver process so that it can use the sched_fifo to give audio threads a higher priority for games that request it. for wineserver to be able to use the rlimits, it needs to have a gid of the @audio that I defined in /etc/security/limits.conf

<greycat> You don't actually think that rlimits magically "pop up" when a process is invoked with a specific UID/GID, do you?
<greycat> rlimits are set within your *own* process and then handed down to your children when you fork/exec thme.
<greycat> Only specific things read pam.d config files -- things that are linked with libpam.
<greycat> Like /bin/login or /usr/sbin/sshd.

<lhunath> greycat: should if I define '@audio - rtprio 90' in /etc/security/limits.conf ;x

<greycat> lhunath: what process do you think reads that file?

<lhunath> pam
<lhunath> hrm.

<greycat> lhunath: and you think that "wine" is linked with libpam?
<greycat> you need to set the limits you want, *and then* run the program you want.
<greycat> it will inherit them.
<greycat> I do stuff like this all the time: su --> ulimit -v whatever --> su - freenet --> start the Freenet node
<greycat> usually exec su - freenet, so that a raw root shell isn't left lying about if/when the freenet processes terminate

<lhunath> heh.

<goldfish> nice

<greycat> See, *this* is why I ask things like "What are you really trying to do"
}}}

This one used to happen a lot. Seriously, at ''least'' once a week, back when Gentoo was more popular:

{{{
<chron> i'm editting a sed stream like: sed 's/^/blah/'
<chron> but i want to replace with 'blah/' instead of 'blah'
<chron> editting a stream*

<greycat> blah\/ or use a different separator

<_matt> blah\//

<chron> thanks
<chron> i'm trying to ls a directory, and every file or folder that shows in ls, i want it to come out like file1 file2 file3 (all in one line)
<chron> instead of columns or list

<greycat> echo *

<trash> chron: echo dir/*

<chron> i'm trying to compare 2 files: file1 and file2, if there is any matching line in file1 from file2, i want it gone from file1

<greycat> !faq subtract
->#bash http://mywiki.wooledge.org/BashFAQ/036 -- How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction).

<trash> !bashphorism2
->#bash The questioner will keep changing the original question until it drives the helpers in the channel insane.
Line 94: Line 131:
&lt;chron&gt; no
&lt;chron&gt;
i know what i'm doing, i swear
&lt;chron&gt; lol

&lt;trash&gt;
I swear you don't.

&lt;chron&gt; cool worked, thanks guys
&lt;chron&gt; i have a file with &lt;package&gt;-&lt;ver&gt; in a list (separate lines), for example: gnu-netcat-0.7.1, and i want to remove -&lt;ver&gt;
&lt;chron&gt;
gnu-netcat-0.7.1 becomes gnu-netcat

&lt;Knirch&gt; !pe
-&gt;#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

&lt;greycat&gt; chron: ${foo%-*}
&lt;greycat&gt; !pe
-&gt;#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

&lt;chron&gt; and that will work even with something like gnu-netcat-0.7.1 ?
&lt;chron&gt; when it has the hyphen after 'gnu'

&lt;greycat&gt; !pe
-&gt;#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

&lt;chron&gt; ok ok

&lt;savetheWorld&gt; foo=gnu-netcat-0.7.1; echo ${foo/-[0-9]*/}

&lt;greycat&gt; savetheWorld: stupid.
<chron> no
<chron>
i know what i'm doing, i swear
<chron> lol

<trash>
I swear you don't.

<chron> cool worked, thanks guys
<chron> i have a file with <package>-<ver> in a list (separate lines), for example: gnu-netcat-0.7.1, and i want to remove -<ver>
<chron>
gnu-netcat-0.7.1 becomes gnu-netcat

<Knirch> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<greycat> chron: ${foo%-*}
<greycat> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<chron> and that will work even with something like gnu-netcat-0.7.1 ?
<chron> when it has the hyphen after 'gnu'

<greycat> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<chron> ok ok

<savetheWorld> foo=gnu-netcat-0.7.1; echo ${foo/-[0-9]*/}

<greycat> savetheWorld: stupid.
Line 125: Line 162:
&lt;chron&gt; how do you do it for every line?

&lt;greycat&gt; !faq 1
-&gt;#bash http://wooledge.org/mywiki/BashFaq#faq1 -- How can I read a file line-by-line?

&lt;greycat&gt; savetheWorld: foo=glibc-2.5-2.5.1
&lt;greycat&gt; in that case, you want glibc-2.5 to be the output, but yours fails.

&lt;savetheWorld&gt; greycat: but I just tested it.
&lt;savetheWorld&gt; foo=glibc-2.5-2.5.1; echo ${foo/-[0-9]*/}
&lt;savetheWorld&gt; glibc

&lt;greycat&gt;
savetheWorld: and that's wrong.

&lt;chron&gt; it's not glibc-2.5

&lt;savetheWorld&gt; ah, rats
&lt;savetheWorld&gt; hmm - right end anchor.... ah, first dash traveling left from the right hand end.

&lt;greycat&gt; which is precisely what ${foo%-*} does

&lt;savetheWorld&gt; ah, didn't see you post that the first time.

&lt;greycat&gt; it was delayed by some lag

&lt;
savetheWorld&gt; and % is non greedy, %% is greedy.
&lt;savetheWorld&gt; right?

&lt;igli&gt; yup

&lt;
savetheWorld&gt; tx

&lt;chron&gt; ok greycat was right, but i needed savetheWorld's solution

&lt;greycat&gt; !bashphorism1
-&gt;#bash the questioner's first description of the problem/question will be misleading.

&lt;chron&gt; lol because some packages look like blah-2.5-r4
&lt;chron&gt; thanks both

&lt;greycat&gt; Has to be a Gentoo user.

&lt;chron&gt; lol
&lt;chron&gt;
quit being so uncanny

&lt;igli&gt; chron: what are you working on?

&lt;chron&gt; emerging all packages in a category
&lt;chron&gt; that are not already merg'd

&lt;igli&gt; all in the whole cat?

&lt;greycat&gt; and the reason you can't just type "emerge blah-2.5-r4" is...?

&lt;trash&gt; he has to type emerge =blah-version

&lt;chron&gt; not only that but

&lt;greycat&gt;
and the reason you can't just type "emerge =blah-2.5-r4" is...? ;-)

&lt;igli&gt; he needs the list first

&lt;chron&gt; i want to get ones that aren't already merg'd

&lt;trash&gt; chron: just add -u

&lt;greycat&gt; !xy
-&gt;#bash http://wooledge.org/mywiki/XyProblem

&lt;chron&gt; and i need to get that not-already-merged list
&lt;chron&gt; into /etc/portage/package.keywords
&lt;chron&gt; i know what i'm doing :&gt;

&lt;igli&gt;
cd /usr/portage/"$cat"; list=($(echo *))

&lt;greycat&gt; You're a gentoo user. By definition, you don't have a clue what you're doing.

&lt;greycat&gt; igli: you mean list=(*)

&lt;savetheWorld&gt; "you keep saying that. I do not think it means what you think it means"..... TPB.

&lt;chron&gt; but my /etc/portage/package.keywords looks very funny with massive comments

&lt;igli&gt; god yes, sorry, just woke up

&lt;chron&gt; no gentoo means i know what i'm doing

&lt;trash&gt; chron: LOL
&lt;trash&gt; that was a good one.

&lt;
savetheWorld&gt; Inconceivable!

&lt;chron&gt; please don't tell me you use debian
&lt;chron&gt; else i'd be laughing for days

&lt;greycat&gt; Now that's a case where LOL was probably literal.

&lt;igli&gt; chron: don't get into this seriously
&lt;igli&gt; #friendly-coders when they've mauled you enuff chron
&lt;igli&gt; ;)

&lt;chron&gt; well i know what i'm doing, and it's already in progress :&gt;

&lt;greycat&gt;
--noreplace (-n)
&lt;greycat&gt; Skips the packages specified on the command-line that have
&lt;greycat&gt; already been installed.

&lt;chron&gt;
yea that's the solution i'm using when i'm doing actually merger
&lt;chron&gt; last step :)

&lt;igli&gt; cd /usr/portage/"$cat"; list=(*); emerge -n ${list[@]}
&lt;igli&gt; cd /usr/portage/"$cat"; list=(*); emerge -n "${list[@]}" # sorry

&lt;greycat&gt; or just cd /usr/portage/"$cat" &amp;&amp; emerge -n *

&lt;igli&gt; heh :)

&lt;greycat&gt; but hey, that would be too obvious and simple!

&lt;igli&gt; "" not needed in gentoo, but best to be safe

&lt;chron&gt; ok i can use that as my last step

&lt;greycat&gt; us poor ignorant Debian and BSD users can't handle his Gentoo elitism.

&lt;igli&gt; chill out greycat :)

&lt;chron&gt; but what i did to get the list in the first place was echo *

&lt;igli&gt; well do that instead

&lt;chron&gt;
cd /usr/portage/$cat &amp;&amp; emerge -n $whateverthatgotechoed
&lt;chron&gt; lolz

&lt;igli&gt; use *

&lt;chron&gt; or i can just copy and paste what i echo *'d

&lt;greycat&gt; emerge -n *

&lt;chron&gt; ah

&lt;igli&gt; indeed

&lt;trash&gt;
indeed lolZ

&lt;chron&gt; lolZ

&lt;igli&gt; hehe that is hilarious
<chron> how do you do it for every line?

<greycat> !faq 1
->#bash http://wooledge.org/mywiki/BashFaq#faq1 -- How can I read a file line-by-line?

<greycat> savetheWorld: foo=glibc-2.5-2.5.1
<greycat> in that case, you want glibc-2.5 to be the output, but yours fails.

<savetheWorld> greycat: but I just tested it.
<savetheWorld> foo=glibc-2.5-2.5.1; echo ${foo/-[0-9]*/}
<savetheWorld> glibc

<greycat>
savetheWorld: and that's wrong.

<chron> it's not glibc-2.5

<savetheWorld> ah, rats
<savetheWorld> hmm - right end anchor.... ah, first dash traveling left from the right hand end.

<greycat> which is precisely what ${foo%-*} does

<savetheWorld> ah, didn't see you post that the first time.

<greycat> it was delayed by some lag

<
savetheWorld> and % is non greedy, %% is greedy.
<savetheWorld> right?

<igli> yup

<
savetheWorld> tx

<chron> ok greycat was right, but i needed savetheWorld's solution

<greycat> !bashphorism1
->#bash the questioner's first description of the problem/question will be misleading.

<chron> lol because some packages look like blah-2.5-r4
<chron> thanks both

<greycat> Has to be a Gentoo user.

<chron> lol
<chron>
quit being so uncanny

<igli> chron: what are you working on?

<chron> emerging all packages in a category
<chron> that are not already merg'd

<igli> all in the whole cat?

<greycat> and the reason you can't just type "emerge blah-2.5-r4" is...?

<trash> he has to type emerge =blah-version

<chron> not only that but

<greycat>
and the reason you can't just type "emerge =blah-2.5-r4" is...? ;-)

<igli> he needs the list first

<chron> i want to get ones that aren't already merg'd

<trash> chron: just add -u

<greycat> !xy
->#bash http://wooledge.org/mywiki/XyProblem

<chron> and i need to get that not-already-merged list
<chron> into /etc/portage/package.keywords
<chron> i know what i'm doing :>

<igli>
cd /usr/portage/"$cat"; list=($(echo *))

<greycat> You're a gentoo user. By definition, you don't have a clue what you're doing.

<greycat> igli: you mean list=(*)

<savetheWorld> "you keep saying that. I do not think it means what you think it means"..... TPB.

<chron> but my /etc/portage/package.keywords looks very funny with massive comments

<igli> god yes, sorry, just woke up

<chron> no gentoo means i know what i'm doing

<trash> chron: LOL
<trash> that was a good one.

<
savetheWorld> Inconceivable!

<chron> please don't tell me you use debian
<chron> else i'd be laughing for days

<greycat> Now that's a case where LOL was probably literal.

<igli> chron: don't get into this seriously
<igli> #friendly-coders when they've mauled you enuff chron
<igli> ;)

<chron> well i know what i'm doing, and it's already in progress :>

<greycat>
--noreplace (-n)
<greycat> Skips the packages specified on the command-line that have
<greycat> already been installed.

<chron>
yea that's the solution i'm using when i'm doing actually merger
<chron> last step :)

<igli> cd /usr/portage/"$cat"; list=(*); emerge -n ${list[@]}
<igli> cd /usr/portage/"$cat"; list=(*); emerge -n "${list[@]}" # sorry

<greycat> or just cd /usr/portage/"$cat" && emerge -n *

<igli> heh :)

<greycat> but hey, that would be too obvious and simple!

<igli> "" not needed in gentoo, but best to be safe

<chron> ok i can use that as my last step

<greycat> us poor ignorant Debian and BSD users can't handle his Gentoo elitism.

<igli> chill out greycat :)

<chron> but what i did to get the list in the first place was echo *

<igli> well do that instead

<chron>
cd /usr/portage/$cat && emerge -n $whateverthatgotechoed
<chron> lolz

<igli> use *

<chron> or i can just copy and paste what i echo *'d

<greycat> emerge -n *

<chron> ah

<igli> indeed

<trash>
indeed lolZ

<chron> lolZ

<igli> hehe that is hilarious
Line 275: Line 312:

[http://floopityjoop.com/sitemap_1.html cat]

The X-Y Problem, as it is sometimes called, is a mental block which leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. It often goes something like this:

  • User wants to do X.
  • User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.
  • User doesn't know how to do Y either.
  • User asks for help with Y.
  • Others try to help user with Y, but are confused because Y seems like a strange problem to want to solve.
  • After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable solution for X.

The problem occurs when people get their train of thought stuck on one approach and become unable to take a step back. Remaining open to having a new look at the bigger picture, these people might find their way back to X and continue searching for alternative solutions.

Here's an example.

<n00b> How can I echo the last three characters in a filename?

<feline> If they're in a variable:  echo ${foo: -3}
<feline> Why 3 characters?  What do you REALLY want?
<feline> Do you want the extension?

<n00b> Yes.

<feline> Then ASK FOR WHAT YOU WANT!
<feline> There's no guarantee that every filename will have a three-letter extension,
<feline> so blindly grabbing three characters does not solve the problem.
<feline> echo ${foo##*.}

Another example:

RikusW> Say I have a filename in $1 how would I get its size ?

greycat> Why?

erUSUL> du $file

RikusW> ty

erUSUL> du "$file" even

RikusW> havent thought of that ... :)

greycat> Literal answers to bad questions can be dangerous.
greycat> WHY do you want its size?  What is the POINT?

RikusW> `du $1` maybe ?
RikusW> Want to write a script to dd  512k sections out and md5sum it...

erUSUL> RikusW: huh? you want to do something with the size later?

greycat> you want to WHAT?

RikusW> dd doesn't return 1 when the end is reached...

greycat> ... why wouldn't you take a SINGLE md5 of the whole thing?

RikusW> I have a corrupt 500mb file....
RikusW> and a slow connection

greycat> rsync.
greycat> NEXT!

Another example:

<lhunath> when starting a process from shell, the process inherits the gid of the shell - I'm looking to start a process with a different GID than my own, so I assumed I should first newgrp to the new group and then start the process - however, newgrp audio gives the following error when run as non-root: Cannot execute bash: No such file or directory
<lhunath> newgrp - audio works, however, but I can't use this in a shell script to start a certain process with a different GID since it spawns a subshell

<greycat> What are you *really* trying to do?

<lhunath> trying to start wine with GID of audio

<greycat> lhunath: well... daemontools includes a setuidgid program that could do it, but to run that, you have to start out as root, and then define a user account whose primary group has the GID you desire.
<greycat> I suspect what you *Really* want to do is "make wine's audio work".  Which means you probably want to add yourself to group 'audio' in /etc/group, and logout and back in.

<lhunath> grin, if only it were that easy. no, what I'm *really* trying to do is to get the rlimits that I set in pam for @audio to apply to the wineserver process so that it can use the sched_fifo to give audio threads a higher priority for games that request it. for wineserver to be able to use the rlimits, it needs to have a gid of the @audio that I defined in /etc/security/limits.conf

<greycat> You don't actually think that rlimits magically "pop up" when a process is invoked with a specific UID/GID, do you?
<greycat> rlimits are set within your *own* process and then handed down to your children when you fork/exec thme.
<greycat> Only specific things read pam.d config files -- things that are linked with libpam.
<greycat> Like /bin/login or /usr/sbin/sshd.

<lhunath> greycat: should if I define '@audio          -       rtprio          90' in /etc/security/limits.conf ;x

<greycat> lhunath: what process do you think reads that file?

<lhunath> pam
<lhunath> hrm.

<greycat> lhunath: and you think that "wine" is linked with libpam?
<greycat> you need to set the limits you want, *and then* run the program you want.
<greycat> it will inherit them.
<greycat> I do stuff like this all the time:    su --> ulimit -v whatever --> su - freenet --> start the Freenet node
<greycat> usually exec su - freenet, so that a raw root shell isn't left lying about if/when the freenet processes terminate

<lhunath> heh.

<goldfish> nice

<greycat> See, *this* is why I ask things like "What are you really trying to do"

This one used to happen a lot. Seriously, at least once a week, back when Gentoo was more popular:

<chron> i'm editting a sed stream like:  sed 's/^/blah/'
<chron> but i want to replace with 'blah/' instead of 'blah'
<chron> editting a stream*

<greycat> blah\/ or use a different separator

<_matt> blah\//

<chron> thanks
<chron> i'm trying to ls a directory, and every file or folder that shows in ls, i want it to come out like file1 file2 file3  (all in one line)
<chron> instead of columns or list

<greycat> echo *

<trash> chron: echo dir/*

<chron> i'm trying to compare 2 files: file1 and file2, if there is any matching line in file1 from file2, i want it gone from file1

<greycat> !faq subtract
->#bash http://mywiki.wooledge.org/BashFAQ/036 -- How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction).

<trash> !bashphorism2
->#bash The questioner will keep changing the original question until it drives the helpers in the channel insane.

* greycat goes out on a limb and guesses that the actual question is "I want to synchronize a directory against another directory"

<chron> no
<chron> i know what i'm doing, i swear
<chron> lol

<trash> I swear you don't.

<chron> cool worked, thanks guys
<chron> i have a file with <package>-<ver> in a list (separate lines), for example: gnu-netcat-0.7.1, and i want to remove -<ver>
<chron> gnu-netcat-0.7.1 becomes gnu-netcat

<Knirch> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<greycat> chron: ${foo%-*}
<greycat> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<chron> and that will work even with something like gnu-netcat-0.7.1 ?
<chron> when it has the hyphen after 'gnu'

<greycat> !pe
->#bash Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

<chron> ok ok

<savetheWorld> foo=gnu-netcat-0.7.1;  echo ${foo/-[0-9]*/}

<greycat> savetheWorld: stupid.

* savetheWorld humbly accepts greycat's gentle critique, begs forgiveness and asks for more information

<chron> how do you do it for every line?

<greycat> !faq 1
->#bash http://wooledge.org/mywiki/BashFaq#faq1 -- How can I read a file line-by-line?

<greycat> savetheWorld: foo=glibc-2.5-2.5.1
<greycat> in that case, you want glibc-2.5 to be the output, but yours fails.

<savetheWorld> greycat: but I just tested it.
<savetheWorld> foo=glibc-2.5-2.5.1;  echo ${foo/-[0-9]*/}
<savetheWorld> glibc

<greycat> savetheWorld: and that's wrong.

<chron> it's not glibc-2.5

<savetheWorld> ah, rats
<savetheWorld> hmm - right end anchor.... ah, first dash traveling left from the right hand end.

<greycat> which is precisely what ${foo%-*} does

<savetheWorld> ah, didn't see you post that the first time.

<greycat> it was delayed by some lag

<savetheWorld> and % is non greedy, %% is greedy.
<savetheWorld> right?

<igli> yup

<savetheWorld> tx

<chron> ok greycat was right, but i needed savetheWorld's solution

<greycat> !bashphorism1
->#bash the questioner's first description of the problem/question will be misleading.

<chron> lol because some packages look like blah-2.5-r4
<chron> thanks both

<greycat> Has to be a Gentoo user.

<chron> lol
<chron> quit being so uncanny

<igli> chron: what are you working on?

<chron> emerging all packages in a category
<chron> that are not already merg'd

<igli> all in the whole cat?

<greycat> and the reason you can't just type "emerge blah-2.5-r4" is...?

<trash> he has to type emerge =blah-version

<chron> not only that but

<greycat> and the reason you can't just type "emerge =blah-2.5-r4" is...? ;-)

<igli> he needs the list first

<chron> i want to get ones that aren't already merg'd

<trash> chron: just add -u

<greycat> !xy
->#bash http://wooledge.org/mywiki/XyProblem

<chron> and i need to get that not-already-merged list
<chron> into /etc/portage/package.keywords
<chron> i know what i'm doing :>

<igli> cd /usr/portage/"$cat"; list=($(echo *))

<greycat> You're a gentoo user.  By definition, you don't have a clue what you're doing.

<greycat> igli: you mean list=(*)

<savetheWorld> "you keep saying that.   I do not think it means what you think it means"..... TPB.

<chron> but my /etc/portage/package.keywords looks very funny with massive comments

<igli> god yes, sorry, just woke up

<chron> no gentoo means i know what i'm doing

<trash> chron: LOL
<trash> that was a good one.

<savetheWorld> Inconceivable!

<chron> please don't tell me you use debian
<chron> else i'd be laughing for days

<greycat> Now that's a case where LOL was probably literal.

<igli> chron: don't get into this seriously
<igli> #friendly-coders when they've mauled you enuff chron
<igli> ;)

<chron> well i know what i'm doing, and it's already in progress :>

<greycat>    --noreplace (-n)
<greycat>           Skips the packages specified on the command-line that have
<greycat>           already been installed.

<chron> yea that's the solution i'm using when i'm doing actually merger
<chron> last step :)

<igli> cd /usr/portage/"$cat"; list=(*); emerge -n ${list[@]}
<igli> cd /usr/portage/"$cat"; list=(*); emerge -n "${list[@]}" # sorry

<greycat> or just cd /usr/portage/"$cat" && emerge -n *

<igli> heh :)

<greycat> but hey, that would be too obvious and simple!

<igli> "" not needed in gentoo, but best to be safe

<chron> ok i can use that as my last step

<greycat> us poor ignorant Debian and BSD users can't handle his Gentoo elitism.

<igli> chill out greycat :)

<chron> but what i did to get the list in the first place was echo *

<igli> well do that instead

<chron> cd /usr/portage/$cat && emerge -n $whateverthatgotechoed
<chron> lolz

<igli> use *

<chron> or i can just copy and paste what i echo *'d

<greycat> emerge -n *

<chron> ah

<igli> indeed

<trash> indeed lolZ

<chron> lolZ

<igli> hehe that is hilarious

XyProblem (last edited 2020-05-03 01:54:18 by GreyCat)