Discussion:
ulimit "command not found" when run from a script on NetBSD
Vincent Stemen
2005-09-19 19:21:29 UTC
Permalink
When I run ulimit from a script with "#!/bin/sh" (with sh sym-linked to
zsh), I get "command not found: ulimit". However, it works fine from
the command line or from a script with "#!/bin/zsh". It also works if
I say "emulate sh" in the script as long as it is not run with
"#!/bin/sh".

Could this be a bug?

zsh version: zsh 4.2.4 (i386--netbsdelf)
--
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://inetaddresses.net/about_NSI.html
Bart Schaefer
2005-09-20 02:07:12 UTC
Permalink
On Sep 19, 2:21pm, Vincent Stemen wrote:
}
} Could this be a bug?

The ulimit builtin comes from the rlimits module. Modules are not
automatically loaded when zsh runs as "sh", to avoid polluting the
variable namespaces or replacing external commands with builtins.

Whether it's noncompliant from a POSIX point of view that "ulimit"
is not a "normal" builtin, I don't know. (I ought to bookmark the
spec one of these days ...)
Andrey Borzenkov
2005-09-20 02:54:57 UTC
Permalink
Post by Bart Schaefer
}
} Could this be a bug?
The ulimit builtin comes from the rlimits module. Modules are not
automatically loaded when zsh runs as "sh", to avoid polluting the
variable namespaces or replacing external commands with builtins.
Whether it's noncompliant from a POSIX point of view that "ulimit"
is not a "normal" builtin, I don't know. (I ought to bookmark the
spec one of these days ...)
well, ulimit shell builtin is part of current SUS:

Since ulimit affects the current shell execution environment, it is always
provided as a shell regular built-in.

I do not have POSIX to check.
Vincent Stemen
2005-09-20 14:54:40 UTC
Permalink
Post by Andrey Borzenkov
Post by Bart Schaefer
}
} Could this be a bug?
The ulimit builtin comes from the rlimits module. Modules are not
automatically loaded when zsh runs as "sh", to avoid polluting the
variable namespaces or replacing external commands with builtins.
Whether it's noncompliant from a POSIX point of view that "ulimit"
is not a "normal" builtin, I don't know. (I ought to bookmark the
spec one of these days ...)
Since ulimit affects the current shell execution environment, it is always
provided as a shell regular built-in.
I do not have POSIX to check.
I just downloaded the posix_std-1003.1-2004 document and it does indeed
say that.

I encountered the problem when running the mysql startup script for
NetBSD using zsh in place of sh. It has the line
ulimit -n 4096
just before it starts up the mysql server. The BSD shell works fine
with it.

Is this something that can be easily corrected in zsh?
--
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://inetaddresses.net/about_NSI.html
Bart Schaefer
2005-09-20 15:57:55 UTC
Permalink
On Sep 20, 9:54am, Vincent Stemen wrote:
} Subject: Re: ulimit "command not found" when run from a script on NetBSD
}
} Is this something that can be easily corrected in zsh?

Most immediately, you can put

zmodload -ab -i zsh/rlimits ulimit

into /etc/zshrc.

Longer-term, the developers need to get the equivalent of that into
the (auto-generated) Src/bltinmods.list file.
Andrey Borzenkov
2005-09-20 16:39:54 UTC
Permalink
Post by Bart Schaefer
} Subject: Re: ulimit "command not found" when run from a script on NetBSD
}
} Is this something that can be easily corrected in zsh?
Most immediately, you can put
zmodload -ab -i zsh/rlimits ulimit
into /etc/zshrc.
Longer-term, the developers need to get the equivalent of that into
the (auto-generated) Src/bltinmods.list file.
what's the point of having it as module then?
Vincent Stemen
2005-09-21 00:30:26 UTC
Permalink
Post by Bart Schaefer
} Subject: Re: ulimit "command not found" when run from a script on NetBSD
}
} Is this something that can be easily corrected in zsh?
Most immediately, you can put
zmodload -ab -i zsh/rlimits ulimit
into /etc/zshrc.
Longer-term, the developers need to get the equivalent of that into
the (auto-generated) Src/bltinmods.list file.
Thanks Bart.

That worked fine. I had to put it in the sh environment script
specified by $ENV, rather than /etc/zshrc, since zsh does not read
/etc/zshrc when run as sh. I just though I would note that for anybody
else who might encounter this issue.

BTW, is there any particular reason there is no mention of the rlimits
module in the manual. I did not find it when I searched zshall(1). It
does cover ulimit under the build-in commands section.

Regards,
Vincent
Bart Schaefer
2005-09-21 02:21:20 UTC
Permalink
On Sep 20, 8:39pm, Andrey Borzenkov wrote:
} Subject: Re: ulimit "command not found" when run from a script on NetBSD
}
}
} On Tuesday 20 September 2005 19:57, Bart Schaefer wrote:
} > Longer-term, the developers need to get the equivalent of that into
} > the (auto-generated) Src/bltinmods.list file.
}
} what's the point of having it as module then?

I never understood why it was made into a module in the first place.
It's static-linked into the main binary so it's not like it's keeping
down the size of the executable.

On the assumption, however, that there was a reason for it (and not
just "because we can"), autoloading ulimit in POSIX mode is needed.
Ideally limit and unlimit would remain disabled unless explicitly
asked for, but that might be more difficult.

On Sep 20, 7:30pm, Vincent Stemen wrote:
} Subject: Re: ulimit "command not found" when run from a script on NetBSD
}
} BTW, is there any particular reason there is no mention of the rlimits
} module in the manual.

Yes; because it's statically linked into the main binary and (except in
sh emulation) all the commands in it are marked for autoloading, so it
does not behave like a module most of the time.

Loading...