On Wed, Apr 16, 2014 at 03:12:35PM +0800, WANG Chao wrote:
On 04/14/14 at 03:53pm, Vivek Goyal wrote:
> On Sun, Apr 13, 2014 at 12:48:47PM +0800, WANG Chao wrote:
>
> [..]
> > > +is_fs_dump_target()
> > > +{
> > > + egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
> > > +}
> > > +
> > > +is_user_configured_dump_target()
> > > +{
> > > + return $(is_ssh_dump_target || is_nfs_dump_target ||
is_raw_dump_target || is_fs_dump_target)
> >
> > Here $() is not correct for use.
> >
> > You should do this:
> >
> > is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target ||
is_fs_dump_target
> >
> > or
> >
> > return is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target ||
is_fs_dump_target
>
> Why it is not correct to call above in a subshell. I am curious to know
> what's wrong with that (apart from performance penalty).
It would go wrong when the subshell returns a string.
One can not return a string from function. I tried it and I got following
message.
return: abc: numeric argument required
And if above functions return string, then non-shell call will also
fails, isn't it. So this is not specific to calling a function in
a sub-shell.
Actually in this case, nothing would go wrong. Because subshell doesn't
return anything back.
I'm just not too keen about such coding style.
I am fine with that. Not calling them in sub-shell will make it faster
too.
Thanks
Vivek