FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 01-18-2009, 11:11 AM
Nils Kassube
 
Default which package a file belongs to

Matthew Flaschen wrote:
> Nils Kassube wrote:
> > dpkg -S /usr/bin/nedit|dpkg -l $(cut -f1 -d':')
>
> Doesn't work. But:
>
> dpkg -l `dpkg -S /usr/bin/nedit|cut -f1 -d':'`
>
> would.

Sorry, I don't understand why it shouldn't work. Here both commands have
the same output.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-18-2009, 03:41 PM
Matthew Flaschen
 
Default which package a file belongs to

Nils Kassube wrote:
> Matthew Flaschen wrote:
>> Nils Kassube wrote:
>>> dpkg -S /usr/bin/nedit|dpkg -l $(cut -f1 -d':')
>> Doesn't work. But:
>>
>> dpkg -l `dpkg -S /usr/bin/nedit|cut -f1 -d':'`
>>
>> would.
>
> Sorry, I don't understand why it shouldn't work. Here both commands have
> the same output.

Nothing is being passed to the cut command, so first you get:

cut: -: Input/output error

then dpkg -l gets no other parameters so prints everything.

Note, this is actually tested.

Matt Flaschen

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-18-2009, 05:49 PM
Nils Kassube
 
Default which package a file belongs to

Matthew Flaschen wrote:
> Nils Kassube wrote:
> > Matthew Flaschen wrote:
> >> Nils Kassube wrote:
> >>> dpkg -S /usr/bin/nedit|dpkg -l $(cut -f1 -d':')
> >>
> >> Doesn't work. But:
> >>
> >> dpkg -l `dpkg -S /usr/bin/nedit|cut -f1 -d':'`
> >>
> >> would.
> >
> > Sorry, I don't understand why it shouldn't work. Here both commands
> > have the same output.
>
> Nothing is being passed to the cut command, so first you get:
>
> cut: -: Input/output error
>
> then dpkg -l gets no other parameters so prints everything.

Now its getting interesting

Actually I had tried the command supplied by the OP and tested what the
output was. I didn't fully evaluate the logic of the command sequence.
Then I modified the command to the version I posted and tested that
version and the output was what I expected.

While your explanation seems logical, the command did work on my machine.
Therefore I made some tests to find out how the shell works with
pipelines and command substitution:

In a new directory make a file first:

$ touch test

How does ls works with a pipe?

$ echo hello | ls
test

Good - like I expected, ls ignores the hello from the pipe. Now, how does
the combination with a command substitution work?

$ echo hello | ls $(cut -f1)
ls: cannot access hello: No such file or directory

OK, so the command substitution reads the pipeline and ls gets the output
of the command substitution.

> Note, this is actually tested.

Like I wrote above, I have tested my version also and here it works. Could
it be that you don't use bash but some other shell? I made the test on my
Kubuntu 8.04 machine first and then I verified that the result is the
same with the Ubuntu 8.10 LiveCD.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-18-2009, 06:13 PM
Matthew Flaschen
 
Default which package a file belongs to

Nils Kassube wrote:
>>> Sorry, I don't understand why it shouldn't work. Here both commands
>>> have the same output.
>> Nothing is being passed to the cut command, so first you get:
>>
>> cut: -: Input/output error
>>
>> then dpkg -l gets no other parameters so prints everything.
>
> Now its getting interesting

Indeed.

> While your explanation seems logical, the command did work on my machine.

Yeah, it works in dash and bash. Apparently, this is an inconsistency
in zsh, my favorite shell.

> $ echo hello | ls $(cut -f1)
> ls: cannot access hello: No such file or directory

That's weird. It seems wrong to me to parse it that way. However, both
bash and dash do do it that way. A simpler test case is:

echo hello | echo $(cat)

zsh give:

cat: -: Input/output error

bash and dash both give hello.

> Like I wrote above, I have tested my version also and here it works. Could
> it be that you don't use bash but some other shell?

I was very surprised that this made a difference. Even with zsh
emulating sh it acts the same. Unfortunately, I don't know enough to
say whether this is a bug or "implementation detail".

However, I would say regardless the explicit version I gave is better.

Matt Flaschen

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 05:36 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org