// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
+//
+// If you are using uClibc, be sure that you've already compiled
+// uClibc with INCLUDE_RPC=true (contained in the Config file)
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
-// Enable ifconfig status reporting output -- this feature adds 12k.
+// Enable ifconfig status reporting output -- this feature adds 7k.
//#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
//
+// Allows "broadcast +" to set broadcast automatically based on hostaddr
+// and netmask, at a cost of about 100 bytes of code (i386).
+//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
+//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
-# define BB_SH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
-# define BB_SH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
-# define BB_SH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
-# define BB_SH
# define shell_main msh_main
#endif
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
-dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c
+dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
+simplify_path.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
ifeq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(LIBBB)
/* Getopts is used by shell procedures to parse positional parameters.
* You probably want to leave this disabled, and use the busybox getopt
* applet if you want to do this sort of thing. There are some scripts
- * out there that use it, so it you need it, enable. Most people will
+ * out there that use it, so if you need it, enable it. Most people will
* leave this disabled. This adds 1k on an x86 system. */
#undef ASH_GETOPTS
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
- * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $
+ * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $
*/
static int timescmd (int argc, char **argv)
{
prog = *argv;
execvp(*argv, argv);
} else {
-#if defined(BB_SH) && defined BB_FEATURE_SH_STANDALONE_SHELL
+#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
prog = *argv;
execvp(*argv, argv);
} else {
-#if defined(BB_SH) && defined BB_FEATURE_SH_STANDALONE_SHELL
+#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
*
*/
-#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
- if (errno) {
+ if (ferror(fp)) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
- errno = 0;
}
if (optind < argc - 1)
putchar('\n');
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
-# define BB_SH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
-# define BB_SH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
-# define BB_SH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
-# define BB_SH
# define shell_main msh_main
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
-# define BB_SH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
-# define BB_SH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
-# define BB_SH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
-# define BB_SH
# define shell_main msh_main
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
-# define BB_SH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
-# define BB_SH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
-# define BB_SH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
-# define BB_SH
# define shell_main msh_main
#endif
*
*/
-#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
- if (errno) {
+ if (ferror(fp)) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
- errno = 0;
}
if (optind < argc - 1)
putchar('\n');
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: ifconfig.c,v 1.11 2001/07/07 05:19:52 andersen Exp $
+ * $Id: ifconfig.c,v 1.11.2.1 2001/08/10 18:22:15 andersen Exp $
*
*/
#define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */
#define A_SET_AFTER 0x40 /* Set a flag at the end. */
#define A_COLON_CHK 0x80 /* Is this needed? See below. */
-#define A_HOSTNAME 0x100 /* Set if it is ip addr. */
-#define A_BROADCAST 0x200 /* Set if it is broadcast addr. */
/*
* These defines are for dealing with the A_CAST_TYPE field.
#define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR)
#define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE)
#define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK)
-#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST)
+#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER)
#define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR)
-#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME)
+#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK)
/*
struct options {
const char *name;
const unsigned char flags;
- const unsigned int arg_flags;
+ const unsigned char arg_flags;
const unsigned short selector;
};
{
struct ifreq ifr;
struct sockaddr_in sai;
- struct sockaddr_in sai_hostname, sai_netmask;
#ifdef BB_FEATURE_IFCONFIG_HW
struct sockaddr sa;
#endif
int selector;
char *p;
char host[128];
- unsigned int mask;
- unsigned int did_flags;
+ unsigned char mask;
+ unsigned char did_flags;
goterr = 0;
did_flags = 0;
}
} else { /* got an arg so process it */
HOSTNAME:
- did_flags |= (mask & (A_NETMASK|A_HOSTNAME));
+ did_flags |= (mask & A_NETMASK);
if (mask & A_CAST_HOST_COPY) {
#ifdef BB_FEATURE_IFCONFIG_HW
if (mask & A_CAST_RESOLVE) {
if (!strcmp(host, "default")) {
/* Default is special, meaning 0.0.0.0. */
sai.sin_addr.s_addr = INADDR_ANY;
- } else if ((!strcmp(host, "+")) && (mask & A_BROADCAST) &&
- (did_flags & (A_NETMASK|A_HOSTNAME))) {
- /* + is special, meaning broadcast is derived. */
- sai.sin_addr.s_addr = (~sai_netmask.sin_addr.s_addr) |
- (sai_hostname.sin_addr.s_addr & sai_netmask.sin_addr.s_addr);
} else if (inet_aton(host, &sai.sin_addr) == 0) {
/* It's not a dotted quad. */
++goterr;
continue;
}
- if(mask & A_HOSTNAME)
- sai_hostname = sai;
- if(mask & A_NETMASK)
- sai_netmask = sai;
p = (char *) &sai;
#ifdef BB_FEATURE_IFCONFIG_HW
} else { /* A_CAST_HOST_COPY_IN_ETHER */
int make_directory (char *path, long mode, int flags);
const char *u_signal_names(const char *str_sig, int *signo, int startnum);
+char *simplify_path(const char *path);
#define CT_AUTO 0
#define CT_UNIX2DOS 1
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $"
+#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $"
+#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
}
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-/* Get the kernel version in the canonical integer form. */
-
-static int get_kernel_version(char str[STRVERSIONLEN])
-{
- struct utsname uts_info;
- int kv;
-
- if (uname(&uts_info) < 0)
- return -1;
- strncpy(str, uts_info.release, STRVERSIONLEN);
-
- kv = get_kernel_revision();
- if(kv==0)
- return -1;
-}
-
/* String comparison for non-co-versioned kernel and module. */
static int ncv_strcmp(const char *a, const char *b)
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
- int k_version;
- char k_strversion[STRVERSIONLEN];
+ struct utsname uts_info;
char m_strversion[STRVERSIONLEN];
int m_version;
int m_crcs;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */
- k_version = get_kernel_version(k_strversion);
+ if (uname(&uts_info) < 0)
+ uts_info.release[0] = '\0';
if (m_has_modinfo) {
m_version = new_get_module_version(f, m_strversion);
} else {
}
}
- if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
+ if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s",
- m_filename, m_strversion, k_strversion);
+ m_filename, m_strversion, uts_info.release);
} else {
error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.",
- m_filename, m_strversion, k_strversion);
+ m_filename, m_strversion, uts_info.release);
goto out;
}
}
int make_directory (char *path, long mode, int flags);
const char *u_signal_names(const char *str_sig, int *signo, int startnum);
+char *simplify_path(const char *path);
#define CT_AUTO 0
#define CT_UNIX2DOS 1
const int extract_function, const char *prefix, char **extract_names)
{
file_header_t *file_entry;
- int found;
+ int extract_flag;
int i;
char *buffer = NULL;
archive_offset = 0;
while ((file_entry = get_headers(src_stream)) != NULL) {
- found = FALSE;
- if (extract_names == NULL) {
- found = TRUE;
- } else {
+ extract_flag = TRUE;
+ if (extract_names != NULL) {
+ int found_flag = FALSE;
for(i = 0; extract_names[i] != 0; i++) {
if (strcmp(extract_names[i], file_entry->name) == 0) {
- found = TRUE;
+ found_flag = TRUE;
+ break;
+ }
+ }
+ if (extract_function & extract_exclude_list) {
+ if (found_flag == TRUE) {
+ extract_flag = FALSE;
+ }
+ } else {
+ /* If its not found in the include list dont extract it */
+ if (found_flag == FALSE) {
+ extract_flag = FALSE;
}
}
+
}
- if (found) {
+ if (extract_flag == TRUE) {
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
} else {
/* seek past the data entry */
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $"
+#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $"
+#ident "$Id: insmod.c,v 1.70.2.1 2001/08/10 18:22:15 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
}
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
-/* Get the kernel version in the canonical integer form. */
-
-static int get_kernel_version(char str[STRVERSIONLEN])
-{
- struct utsname uts_info;
- int kv;
-
- if (uname(&uts_info) < 0)
- return -1;
- strncpy(str, uts_info.release, STRVERSIONLEN);
-
- kv = get_kernel_revision();
- if(kv==0)
- return -1;
-}
-
/* String comparison for non-co-versioned kernel and module. */
static int ncv_strcmp(const char *a, const char *b)
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
- int k_version;
- char k_strversion[STRVERSIONLEN];
+ struct utsname uts_info;
char m_strversion[STRVERSIONLEN];
int m_version;
int m_crcs;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */
- k_version = get_kernel_version(k_strversion);
+ if (uname(&uts_info) < 0)
+ uts_info.release[0] = '\0';
if (m_has_modinfo) {
m_version = new_get_module_version(f, m_strversion);
} else {
}
}
- if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
+ if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s",
- m_filename, m_strversion, k_strversion);
+ m_filename, m_strversion, uts_info.release);
} else {
error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.",
- m_filename, m_strversion, k_strversion);
+ m_filename, m_strversion, uts_info.release);
goto out;
}
}
if (optind < argc) {
/* if device is a filename get its real path */
if (stat(argv[optind], &statbuf) == 0) {
- realpath(argv[optind], device);
+ device = simplify_path(argv[optind]);
} else {
safe_strncpy(device, argv[optind], PATH_MAX);
}
}
- if (optind + 1 < argc) {
- if (realpath(argv[optind + 1], directory) == NULL) {
- perror_msg_and_die("%s", directory);
- }
- }
-
+ if (optind + 1 < argc)
+ directory = simplify_path(argv[optind + 1]);
+
if (all == TRUE || optind + 1 == argc) {
struct mntent *m = NULL;
FILE *f = setmntent("/etc/fstab", "r");
ronly(vp)
struct var *vp;
{
- if (isalpha(vp->name[0])) /* not an internal symbol ($# etc) */
+ if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */
vp->status |= RONLY;
}
isassign(s)
register char *s;
{
- if (!isalpha((int)*s))
+ if (!isalpha((int)*s) && *s != '_')
return(0);
for (; *s != '='; s++)
- if (*s == 0 || !isalnum(*s))
+ if (*s == 0 || (!isalnum(*s) && *s != '_'))
return(0);
return(1);
}
register char *cp;
struct var *vp;
- if (!isalpha(*s))
+ if (!isalpha(*s) && *s != '_')
return(0);
for (cp = s; *cp != '='; cp++)
- if (*cp == 0 || !isalnum(*cp))
+ if (*cp == 0 || (!isalnum(*cp) && *cp != '_'))
return(0);
vp = lookup(s);
nameval(vp, ++cp, cf == COPYV? (char *)NULL: s);
checkname(cp)
register char *cp;
{
- if (!isalpha(*cp++))
+ if (!isalpha(*cp++) && *(cp-1) != '_')
return(0);
while (*cp)
- if (!isalnum(*cp++))
+ if (!isalnum(*cp++) && *(cp-1) != '_')
return(0);
return(1);
}
register struct var *vp;
for (vp = vlist; vp; vp = vp->next)
- if (vp->status & f && isalpha(*vp->name)) {
+ if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) {
if (vp->status & EXPORT)
write(out, "export ", 7);
if (vp->status & RONLY)
register char *s;
int out;
{
- if (isalnum(*s)) {
+ if (isalnum(*s) || *s == '_') {
write(out, s, strlen(s));
write(out, "\n", 1);
}
c = 0;
}
unget(c);
- if (!isalpha(c))
+ if (!isalpha(c) && c != '_')
scanequals = 0;
for (;;) {
c = subgetc('"', foundequals);
foundequals = 1;
scanequals = 0;
}
- else if (!isalnum(c))
+ else if (!isalnum(c) && c != '_')
scanequals = 0;
}
*e.linep++ = c;
s = e.linep;
if (c != '{') {
*e.linep++ = c;
- if (isalpha(c)) {
- while ((c = readc())!=0 && isalnum(c))
+ if (isalpha(c) || c == '_') {
+ while ((c = readc())!=0 && (isalnum(c) || c == '_'))
if (e.linep < elinep)
*e.linep++ = c;
unget(c);
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: ifconfig.c,v 1.11 2001/07/07 05:19:52 andersen Exp $
+ * $Id: ifconfig.c,v 1.11.2.1 2001/08/10 18:22:15 andersen Exp $
*
*/
#define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */
#define A_SET_AFTER 0x40 /* Set a flag at the end. */
#define A_COLON_CHK 0x80 /* Is this needed? See below. */
-#define A_HOSTNAME 0x100 /* Set if it is ip addr. */
-#define A_BROADCAST 0x200 /* Set if it is broadcast addr. */
/*
* These defines are for dealing with the A_CAST_TYPE field.
#define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR)
#define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE)
#define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK)
-#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST)
+#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER)
#define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR)
-#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME)
+#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK)
/*
struct options {
const char *name;
const unsigned char flags;
- const unsigned int arg_flags;
+ const unsigned char arg_flags;
const unsigned short selector;
};
{
struct ifreq ifr;
struct sockaddr_in sai;
- struct sockaddr_in sai_hostname, sai_netmask;
#ifdef BB_FEATURE_IFCONFIG_HW
struct sockaddr sa;
#endif
int selector;
char *p;
char host[128];
- unsigned int mask;
- unsigned int did_flags;
+ unsigned char mask;
+ unsigned char did_flags;
goterr = 0;
did_flags = 0;
}
} else { /* got an arg so process it */
HOSTNAME:
- did_flags |= (mask & (A_NETMASK|A_HOSTNAME));
+ did_flags |= (mask & A_NETMASK);
if (mask & A_CAST_HOST_COPY) {
#ifdef BB_FEATURE_IFCONFIG_HW
if (mask & A_CAST_RESOLVE) {
if (!strcmp(host, "default")) {
/* Default is special, meaning 0.0.0.0. */
sai.sin_addr.s_addr = INADDR_ANY;
- } else if ((!strcmp(host, "+")) && (mask & A_BROADCAST) &&
- (did_flags & (A_NETMASK|A_HOSTNAME))) {
- /* + is special, meaning broadcast is derived. */
- sai.sin_addr.s_addr = (~sai_netmask.sin_addr.s_addr) |
- (sai_hostname.sin_addr.s_addr & sai_netmask.sin_addr.s_addr);
} else if (inet_aton(host, &sai.sin_addr) == 0) {
/* It's not a dotted quad. */
++goterr;
continue;
}
- if(mask & A_HOSTNAME)
- sai_hostname = sai;
- if(mask & A_NETMASK)
- sai_netmask = sai;
p = (char *) &sai;
#ifdef BB_FEATURE_IFCONFIG_HW
} else { /* A_CAST_HOST_COPY_IN_ETHER */
/* Getopts is used by shell procedures to parse positional parameters.
* You probably want to leave this disabled, and use the busybox getopt
* applet if you want to do this sort of thing. There are some scripts
- * out there that use it, so it you need it, enable. Most people will
+ * out there that use it, so if you need it, enable it. Most people will
* leave this disabled. This adds 1k on an x86 system. */
#undef ASH_GETOPTS
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
- * $Id: ash.c,v 1.17 2001/08/02 05:02:45 andersen Exp $
+ * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $
*/
static int timescmd (int argc, char **argv)
{
ronly(vp)
struct var *vp;
{
- if (isalpha(vp->name[0])) /* not an internal symbol ($# etc) */
+ if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */
vp->status |= RONLY;
}
isassign(s)
register char *s;
{
- if (!isalpha((int)*s))
+ if (!isalpha((int)*s) && *s != '_')
return(0);
for (; *s != '='; s++)
- if (*s == 0 || !isalnum(*s))
+ if (*s == 0 || (!isalnum(*s) && *s != '_'))
return(0);
return(1);
}
register char *cp;
struct var *vp;
- if (!isalpha(*s))
+ if (!isalpha(*s) && *s != '_')
return(0);
for (cp = s; *cp != '='; cp++)
- if (*cp == 0 || !isalnum(*cp))
+ if (*cp == 0 || (!isalnum(*cp) && *cp != '_'))
return(0);
vp = lookup(s);
nameval(vp, ++cp, cf == COPYV? (char *)NULL: s);
checkname(cp)
register char *cp;
{
- if (!isalpha(*cp++))
+ if (!isalpha(*cp++) && *(cp-1) != '_')
return(0);
while (*cp)
- if (!isalnum(*cp++))
+ if (!isalnum(*cp++) && *(cp-1) != '_')
return(0);
return(1);
}
register struct var *vp;
for (vp = vlist; vp; vp = vp->next)
- if (vp->status & f && isalpha(*vp->name)) {
+ if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) {
if (vp->status & EXPORT)
write(out, "export ", 7);
if (vp->status & RONLY)
register char *s;
int out;
{
- if (isalnum(*s)) {
+ if (isalnum(*s) || *s == '_') {
write(out, s, strlen(s));
write(out, "\n", 1);
}
c = 0;
}
unget(c);
- if (!isalpha(c))
+ if (!isalpha(c) && c != '_')
scanequals = 0;
for (;;) {
c = subgetc('"', foundequals);
foundequals = 1;
scanequals = 0;
}
- else if (!isalnum(c))
+ else if (!isalnum(c) && c != '_')
scanequals = 0;
}
*e.linep++ = c;
s = e.linep;
if (c != '{') {
*e.linep++ = c;
- if (isalpha(c)) {
- while ((c = readc())!=0 && isalnum(c))
+ if (isalpha(c) || c == '_') {
+ while ((c = readc())!=0 && (isalnum(c) || c == '_'))
if (e.linep < elinep)
*e.linep++ = c;
unget(c);
if (optind < argc) {
/* if device is a filename get its real path */
if (stat(argv[optind], &statbuf) == 0) {
- realpath(argv[optind], device);
+ device = simplify_path(argv[optind]);
} else {
safe_strncpy(device, argv[optind], PATH_MAX);
}
}
- if (optind + 1 < argc) {
- if (realpath(argv[optind + 1], directory) == NULL) {
- perror_msg_and_die("%s", directory);
- }
- }
-
+ if (optind + 1 < argc)
+ directory = simplify_path(argv[optind + 1]);
+
if (all == TRUE || optind + 1 == argc) {
struct mntent *m = NULL;
FILE *f = setmntent("/etc/fstab", "r");