51 Commits

Author SHA1 Message Date
Herbert Xu
4bbf8721a3 Release 0.5.12. 2022-12-11 14:33:43 +08:00
Herbert Xu
6f6d1f2da0 shell: Call CHECK_DECL on stat64
On macOS it is possible to find stat64 at link-time but not at
compile-time.  To make the build process more robust we should
check for the header file as well as the library.

Reported-by: Saagar Jha <saagar@saagarjha.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2021-06-04 11:35:44 +08:00
C. McEnroe
c1166e98c1 shell: Fail if building --with-libedit and can't find libedit
Previously, configure --with-libedit would only fail in the case where
libedit is available but its header file histedit.h is not.

Fixes: 13537aaa484b ("[BUILD] Added --with-libedit option to...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2021-01-13 17:20:45 +11:00
Herbert Xu
1f6fc2dc2f shell: Disable glob again as it strips traing slashes
On Mon, Nov 16, 2020 at 01:47:48PM +1100, Herbert Xu wrote:
> René Scharfe <l.s.r@web.de> wrote:
> >
> > on Debian testing dash eats trailing slashes of parameters that happen
> > to be regular files when expanding "$@".  Example:
> >
> >   $ rm -f foo bar
> >   $ touch foo
> >   $ dash -c 'echo "$0" "$@"' baz foo/ bar/ ./
> >   baz foo bar/ ./
>
> In fact you just have to do
>
> 	dash -c 'echo bar\/'
>
> This is a bug in glob(3).  It's stripping the slash.
>
> I guess we'll just have to disable glob again.

This patch disables glob(3) by default.

Reported-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-12-23 18:55:20 +11:00
Herbert Xu
6ba88b3ed2 shell: Group readdir64/dirent64 with open64
The test for open64 is separate from stat64 for macOS.  However,
the newly introduced tests for readdir64/dirent64 should be grouped
with open64 instead of stat64 as otherwise they cause similar build
failures.

Reported-by: Martijn Dekker <martijn@inlv.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-08-28 13:01:28 +10:00
Herbert Xu
a09fe58449 expand: Make glob(3) interruptible by SIGINT
If glob(3) is used then it can't be interrupted by SIGINT.  This
is bad when an expansion causes a large number of entries to be
generated.  This patch improves things by adding an int_pending
check to gl_opendir call.  Note that this is still not perfect,
e.g., the sort would still be uninterruptible.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-07-08 16:58:29 +10:00
Herbert Xu
7638476c18 shell: Enable fnmatch/glob by default
As fnmatch(3) and glob(3) from glibc are now working consistently,
this patch enables them by default.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-06-01 23:28:36 +10:00
Herbert Xu
39279293fa Release 0.5.11. 2020-06-01 23:13:28 +10:00
Herbert Xu
3e3e7af1a4 shell: Always use explicit large file API
There are some remaining stat/readdir calls in dash that may lead
to spurious EOVERFLOW errors on 32-bit platforms.  This patch changes
them (as well as open(2)) to use the explicit large file API.

Reported-by: Tatsuki Sugiura <sugi@nemui.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-05-15 16:24:38 +10:00
Fangrui Song
f30bd155cc shell: delete AC_PROG_YACC
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-01-20 17:53:39 +08:00
Antonio Ospite
ef2ab7b23b shell: Enable automake silent rules
Enable automake silent rules to make it easier to spot compilation
problems.

Silent rules will be enabled by default, but only if they are available,
in order to keep compatibility with older autotools versions.

Prepend the silent strings also to custom rules.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-12-14 13:48:02 +08:00
Antonio Ospite
49cd009217 shell: Update configure.ac with suggestions from autoupdate
Apply the changes suggested by running autoupdate on the source
repository:

1. Properly quote AC_INIT arguments.

2. Use AC_USE_SYSTEM_EXTENSIONS instead of AC_GNU_SOURCE. The former is
   a superset of the latter, and enables more options, see
   https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/Posix-Variants.html

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-12-14 13:48:02 +08:00
Herbert Xu
0e6a3d2081 Release 0.5.10.2. 2018-05-17 19:09:37 +08:00
Herbert Xu
39404b4f8a Release 0.5.10.1. 2018-05-10 16:06:42 +08:00
Herbert Xu
8e942c0ee8 Release 0.5.10. 2018-05-03 16:46:50 +08:00
Jason Bowen
e695774716 shell: Add subdir-objects to AM_INIT_AUTOMAKE
I've attached a patch which adds the subdir-objects option to AM_INIT_AUTOMAKE.

For a while now when I've compiled dash I received a warning from
automake that there are source files in a subdirectory but that the
subdir-objects automake option was not supplied. I've just been adding
it myself, but I finally got around to submitting a patch. The code
still compiles for now (i'm using automake 1.15.1), but warning text
is rarely nice to see and, if the warning text is to be believed, then
the warning will eventually become an error.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-04-19 18:19:29 +08:00
Martijn Dekker
fc914153d4 builtin: Greater resolution in test -nt / test -ot
Op 07-03-18 om 15:46 schreef Martijn Dekker:
> Op 06-03-18 om 09:19 schreef Herbert Xu:
>> On Thu, Jun 22, 2017 at 10:30:02AM +0200, Petr Skočík wrote:
>>> would you be willing to pull something like this?
> [...]
>>> I could use greater resolution in `test -nt` / `test -ot`, and st_mtim
>>> field is standardized under POSIX.1-2008 (or so stat(2) says).
>>
>> Sure.  But your patch is corrupted.
>
> Fixed patch attached.
>
> But I wouldn't apply it as is. My system does not have st_mtim. So I
> think it needs a configure test and a fallback to the old method.

Here's an attempt to make that happen. See attached.

- M.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-03-22 00:25:35 +08:00
Herbert Xu
afe0e0152e Release 0.5.9.1. 2016-09-23 22:51:48 +08:00
Herbert Xu
801fbd560d Release 0.5.9. 2016-06-06 12:48:52 +08:00
Jonathan Nieder
f6d4def4e2 [BUILTIN] Fix "test -x" as root on FreeBSD 8
POSIX.1-2008 §4.4 "File Access Permission" sayeth:

	If execute permission is requested, access shall be granted
	if execute permission is granted to at least one user by the
	file permission bits or by an alternate access control
	mechanism; otherwise, access shall be denied.

For historical reasons, POSIX unfortunately also allows access() and
faccessat() to return success for X_OK if the current process is
privileged, even when the above condition is not fulfilled and actual
execution would fail.  On the affected platforms, "test -x <path>" as
root started returning true on nonexecutable files when dash switched
from its own emulation to the true faccessat in v0.5.7~54
(2010-04-02).

Work around this by checking the permissions bits when mode == X_OK
and geteuid() == 0 on such platforms.

Unfortunately the behavior seems to vary from one kernel version to
another, so we cannot just check the behavior at compile time and rely
on that.  A survey of some affected kernels:

 - NetBSD's kernel moved to the sane semantics in 1997
 - OpenBSD's kernel made the same change in version 4.4, three years
   ago
 - FreeBSD 9's kernel fixes this but hasn't been released yet

It seems safe to only apply the workaround on systems using the
FreeBSD kernel for now, and to push for standardization on the
expected access()/faccessat() semantics so we can drop the workaround
altogether in a few years.

To try it on other platforms, use "./configure --enable-test-workaround".

Reported-by: Christoph Egger <christoph@debian.org>
Analysis-by: Petr Salinger <Petr.Salinger@seznam.cz>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2014-11-17 22:51:37 +08:00
Herbert Xu
f21016a126 Release 0.5.8. 2014-09-26 22:27:20 +08:00
David S. Miller
4da0e221ba [SHELL] Allow building without LINEO support
Simply specify --disable-lineno to configure.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2011-08-17 09:34:47 +08:00
Harald van Dijk
b5bda1d94f [ARITH] Avoid imaxdiv when only one of the results is wanted
dash rather pointlessly calls imaxdiv, only to discard one of its
results. The call was already made conditional a while back because some
systems don't have imaxdiv, but the generated code for the version with
imaxdiv and the one with / and % is identical (with GCC 4.6.1 or ICC
12.0.2, with -O0, -O2 or -Os), so it could just as well go entirely to
clean up the code a little bit.

Signed-off-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2011-08-17 09:28:24 +08:00
Herbert Xu
481e761788 Release 0.5.7. 2011-07-08 17:00:50 +08:00
Brian Koropoff
bfcdc49695 [SHELL] Port to Solaris
- Solaris lacks paths.h and the various _PATH_* #defines.
  Check for them in configure.ac and fall back on the
  usual suspects when they are missing.

- Older Solaris lacks isblank(), and versions that have it
  use a macro.  Check for the declaration in configure.ac
  and fall back on a naive version when missing.

- Older Solaris does not support %jd (intmax_t) in format
  strings, but it does support the PRIdMAX macro from inttypes.h.
  Do a configure check for PRIdMAX and use it in the code.
  If it doesn't exist, define it to "lld" when sizeof(long long)
  equals sizeof(intmax_t) as this is more likely to work on
  older systems.  Otherwise, use "jd" and hope for the best.

- Older Solaris lacks stdint.h, but inttypes.h provides the
  same types and works on all platforms I've tried dash on,
  so just use it instead.

- Older Solaris doesn't like it when vsnprintf() is passed
  a NULL buffer (in violation of the POSIX spec, of course).
  Pass a 1-byte dummy buffer instead.

- Solaris lacks tempfile and mktemp programs.  Fall back on a
  "good-enough" custom function in mkbuiltins.

Signed-off-by: Brian Koropoff <bkoropoff@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2011-03-15 15:35:14 +08:00
Herbert Xu
1d68712ba2 [BUILTIN] Use faccessat if available
Eric Blake suggested that we should use faccessat so that ACLs
and other corner cases are handled correctly.  This patch does
exactly that.

Note that faccessat doesn't handle ACLs when euid != uid, as
this case is currently implemented by glibc instead of the kernel,
using code similar to the existing dash test.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2010-04-02 22:02:22 +08:00
Herbert Xu
02a568bb14 Release 0.5.6. 2010-04-02 14:17:03 +08:00
Herbert Xu
6045fe2507 Release 0.5.5.1. 2009-01-14 10:36:46 +11:00
Herbert Xu
623b387956 Release 0.5.5. 2009-01-13 15:23:33 +11:00
Mark Mentovai
45d2ed8307 [BUILD] Fixed build on OS X
Hi, Herbert and friends.  I've created a small patch that allows dash
to be built on Mac OS X.  I'm contributing it here with the hope that
it's suitable for inclusion in dash.

The changes in this patch are:

- __attribute__((__alias__())) is not supported, add an autoconf check
- open64 is not present although the stat64 family is, separate the
  autoconf checks
- A syntax error had slipped into a non-glibc codepath
- mkbuiltins had a nonportable mktemp invocation for the case where
  tempfile is not availalble

Nothing in this patch is actually Mac OS X-specific, so it might aid
portability to other platforms as well.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2009-01-13 15:21:35 +11:00
Aleksey Cheusov
508d3a2b0e [BUILD] Fixed build on NetBSD
Hi, I propose to apply the following patch for dash.  The problem is
alloca.h is absent on many platforms including NetBSD I'm running.

Also, NetBSD's version of mktemp doesn't work without temporary
filename pattern.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2009-01-13 14:57:41 +11:00
Gerrit Pape
469fad8670 [ARITH] If imaxdiv() isn't available, use / and % operators
Although in posix, imaxdiv() isn't implemented on Debian/alpha, causing
dash to fail to build.  So use / and % operators if imaxdiv() isn't
available.

 http://bugs.debian.org/456398

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-12-23 21:24:37 +08:00
Herbert Xu
a20ba85f69 [EXPAND] Added configure --enable-glob and --enable-fnmatch options
Debian's libc6 as of 2.6.1-6 has working glob(3)/fnmatch(3) support.
This patch adds the options --enable-glob and --enable-fnmatch to
the configure script.  By default glob(3) and fnmatch(3) are still
unused.  However, on distros where the glibc is known to work you
may enable these options.
2007-10-20 18:26:23 +08:00
Alexey Gladkov
12dc49683b [BUILD] Add --enable-static option to configure.
Add new option to build statical linked dash.
2007-10-04 14:21:44 +08:00
Herbert Xu
e592f4dfe8 Release 0.5.4. 2007-07-12 17:32:51 +08:00
Alexey Gladkov
13537aaa48 [BUILD] Added --with-libedit option to configure
Add to the configure.ac new option:
--with-libedit - Compile with libedit support.
2006-05-23 20:52:23 +10:00
Herbert Xu
c49ef4ee9f Release 0.5.3. 2005-11-26 14:15:04 +11:00
Herbert Xu
8706dedec7 [SYSTEM] Added out-of-line ctypes functions for klibc
Unfortunately klibc doesn't provide out-of-line versions of ctypes
functions such as isalpha.  This is a nasty hack to create them.
2005-10-29 22:11:56 +10:00
Herbert Xu
156deb8fa7 [SYSTEM] Added dummy sysconf implementation
Add a dummy sysconf implementation that always fails for klibc.
2005-10-29 21:43:45 +10:00
Herbert Xu
751f4eeb22 [SYSTEM] Added dummy strtod implementation
klibc doesn't have strtod or atof.  So add an implementation that
always fails by setting the end pointer to the input string.
2005-10-29 21:40:05 +10:00
Herbert Xu
f97c2127a6 [BUILTIN] Disable ulimit if there is no getrlimit
For systems without getrlimit (e.g., klibc) we will disable ulimit.

In order to achieve this, builtins.def is now produced by cpp which
allows us to use macros such as HAVE_GETRLIMIT in it.

Thie also means that we can get rid of the cflags parsing code in
mkbuiltins.
2005-10-29 21:40:05 +10:00
Herbert Xu
14c0903ea8 [SIGNAL] Added default implementation of killpg
klibc doesn't have killpg.  Since we only call it for valid values of
pid, we can call kill instead.
2005-10-29 21:40:05 +10:00
Herbert Xu
f084cc9a34 [SIGNAL] Added default implementation of strsignal
klibc doesn't have strsignal but it does have sys_siglist.
2005-10-29 21:39:47 +10:00
Herbert Xu
6fd1b08628 [EXPAND] Added getpwhome as a wrapper for getpwnam
klibc doesn't have and doesn't need getpwnam.  This change creates
getpwhome which always returns NULL if getpwnam doesn't exist.
2005-10-29 16:01:07 +10:00
Herbert Xu
95325feb5a [SYSTEM] Added default implementation of bsearch
Added impelmentation of bsearch since klibc doesn't have it yet.
2005-10-29 15:17:47 +10:00
Herbert Xu
cee8660318 Use stat if stat64 does not exist
64-bit file calls such as stat64 don't exist on all architectures for
dietlibc, and they don't exist at all for klibc.  In those cases the
normal calls such as stat are already 64-bit.

So simply define stat64 as stat if it doesn't exist.  Do the same for
all other 64-bit calls as well.
2005-10-29 14:31:40 +10:00
Herbert Xu
90829c10d5 [SIGNAL] Use bsd_signal if it exists and signal does not
klibc has bsd_signal instead of signal.  So we will define signal as
bsd_signal if

1) signal does not exist.
2) bsd_signal exists.
2005-10-29 14:15:26 +10:00
Herbert Xu
16399b9071 Copyright/licence updates and remove all traces of sys/cdefs.h
This change updates the BSD licence to the three-clause version since
NetBSD has already done so.  This makes dash GPL-compatible.

It also adds Christos Zoulas (NetBSD ash maintainer) to the COPYING file.
I've added "copyright by Herbert Xu" to most files.

Finally all CVS IDs and inclusion of sys/cdefs.h have been removed.
The latter is needed for support of klibc.
2005-10-29 11:26:30 +10:00
gilles.chanteperdrix
abbb74506f Fixed support for cross-compilation. 2005-09-26 18:33:04 +10:00
herbert
1b5dcb2f59 Release 0.5.2.
TAG: v0.5.2
2005-09-26 18:33:03 +10:00