[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] A do nothing function
From: |
Peng Yu |
Subject: |
Re: [Help-bash] A do nothing function |
Date: |
Thu, 27 Sep 2012 12:13:18 -0500 |
For example, I have to conditions to tests and depending on the condition
function cmd1 {
if [ $cnd1 ]
then
blah1
else
cat
fi
}
function cmd2 {
if [ $cnd2 ]
then
blah2
else
cat
fi
}
cmd1 | cmd2
Because using cat is not efficient, a more efficient way might be. But
nested if is very hard to read. So still the above is better in terms
of readability. That's why I'm looking for a better way to avoid cat.
if [ $cnd1 ]
then
if [ $cnd2 ]
then
blah1 | blah2
else
blah1
fi
else
if [ $cnd2 ]
then
blah2
else
cat
fi
fi
The following was sent incorrectly.
On Thu, Sep 27, 2012 at 12:07 PM, Peng Yu <address@hidden> wrote:
> For example, in pseudo code
>
> function cmd1 {
> if some condition
>
> }
>
>
>
> On Thu, Sep 27, 2012 at 11:38 AM, DJ Mills <address@hidden> wrote:
>> On Thu, Sep 27, 2012 at 12:24 PM, Peng Yu <address@hidden> wrote:
>>> Hi,
>>>
>>> I have to use cat if just want to pass the stdin to stdout. But this
>>> requires calling cat. Is there a more efficient way to just past stdin
>>> to stdout?
>>>
>>> /tmp$ cat test.sh
>>> #!/usr/bin/env bash
>>>
>>> function cmd {
>>> cat
>>> }
>>>
>>> echo xxxx | cmd | cat
>>>
>>> --
>>> Regards,
>>> Peng
>>>
>>
>> No, cat's the easiest/best way to accomplish that.
>> However, that raises the question of why you wouldn't ust omit the whole
>> thing
>
>
>
> --
> Regards,
> Peng
--
Regards,
Peng
- [Help-bash] A do nothing function, Peng Yu, 2012/09/27
- Re: [Help-bash] A do nothing function, DJ Mills, 2012/09/27
- Re: [Help-bash] A do nothing function, Bob Proulx, 2012/09/27
- Re: [Help-bash] A do nothing function, Greg Wooledge, 2012/09/28
- Re: [Help-bash] A do nothing function, DJ Mills, 2012/09/28
- Re: [Help-bash] A do nothing function, Bob Proulx, 2012/09/28
- Re: [Help-bash] A do nothing function, Greg Wooledge, 2012/09/28
- Re: [Help-bash] A do nothing function, Bob Proulx, 2012/09/28
- Re: [Help-bash] A do nothing function, Stephane Chazelas, 2012/09/29
Re: [Help-bash] A do nothing function, Davide Brini, 2012/09/27