diff --git a/bash-5.1/.cargo/config.toml b/bash-5.1/.cargo/config.toml
index 11bdee268c6482560d4bb54326142673fb3ff073..75e93c385bd56c7098600e76ed55f0e9128d965c 100644
--- a/bash-5.1/.cargo/config.toml
+++ b/bash-5.1/.cargo/config.toml
@@ -1,3 +1,4 @@
+
[source.crates-io]
replace-with = "vendored-sources"
diff --git a/bash-5.1/1.sh b/bash-5.1/1.sh
new file mode 100755
index 0000000000000000000000000000000000000000..bcc830c919ba01181ba3fec57fe993de260c3a29
--- /dev/null
+++ b/bash-5.1/1.sh
@@ -0,0 +1,21 @@
+cd /home/huan/gerrit/bash/
+git log --pretty=format:"%H $ %s" >2
+cat 2|tac >1
+
+while read line ; do echo $line|awk -F'$' '{
+print " cd /home/huan/gerrit/utshell/ ; ";
+print " git checkout master; git pull ;";
+print " git checkout -b " $1 " ; ";
+print " cd /home/tong/src/bash/ ;";
+print "git reset --hard ",$1," ; ";
+print "cp -r /home/huan/gerrit/bash/* /home/huan/gerrit/utshell/";
+print "cd /home/huan/gerrit/utshell/";
+print "echo \"" $1 "\" >> record.txt";
+print "git add .;"
+print "git commit -m \"" , $2,"\"";
+print "git push --set-upstream origin " $1;
+print "git checkout master; ";
+print "cd /home/huan/gerrit/bash ";
+print "sleep 10";
+print "read"
+}' ; done < ../1>./1.sh
diff --git a/bash-5.1/Makefile b/bash-5.1/Makefile
deleted file mode 100644
index 158066deeff8e7ea606953e70fbe550128e864b3..0000000000000000000000000000000000000000
--- a/bash-5.1/Makefile
+++ /dev/null
@@ -1,1754 +0,0 @@
-# Makefile for bash-5.0, version 4.30
-#
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-# Make sure the first target in the makefile is the right one
-all: .made
-
-PACKAGE = rash
-VERSION = 0.1-release
-
-PACKAGE_BUGREPORT = bug-rash@gnu.org
-PACKAGE_NAME = rash
-PACKAGE_STRING = rash 0.1-release
-PACKAGE_VERSION = 0.1-release
-
-PACKAGE_TARNAME = rash
-
-# Include some boilerplate Gnu makefile definitions.
-prefix = /usr/local
-
-exec_prefix = ${prefix}
-
-datarootdir = ${prefix}/share
-
-bindir = ${exec_prefix}/bin
-libdir = ${exec_prefix}/lib
-infodir = ${datarootdir}/info
-includedir = ${prefix}/include
-datadir = ${datarootdir}
-localedir = ${datarootdir}/locale
-pkgconfigdir = ${libdir}/pkgconfig
-
-loadablesdir = ${libdir}/bash
-headersdir = $(includedir)/$(PACKAGE_NAME)
-
-docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
-
-mandir = ${datarootdir}/man
-manpfx = man
-
-man1ext = .1
-man1dir = $(mandir)/$(manpfx)1
-man3ext = .3
-man3dir = $(mandir)/$(manpfx)3
-
-htmldir = ${docdir}
-
-# Support an alternate destination root directory for package building
-DESTDIR =
-
-topdir = .
-BUILD_DIR = /home/tong/src/bash/bash-5.1
-top_builddir = /home/tong/src/bash/bash-5.1
-srcdir = .
-
-
-
-CC = gcc
-CC_FOR_BUILD = $(CC)
-YACC = bison -y
-SHELL = /bin/sh
-CP = cp
-RM = rm -f
-AR = ar
-ARFLAGS = cr
-RANLIB = ranlib
-SIZE = size
-STRIP = strip
-
-INSTALL = /usr/bin/install -c
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_SCRIPT = ${INSTALL}
-INSTALL_DATA = ${INSTALL} -m 644
-INSTALLMODE= -m 0755
-INSTALLMODE2 = -m 0555
-
-TESTSCRIPT = run-all
-
-DEBUGGER_START_FILE = ${datadir}/bashdb/bashdb-main.inc
-
-#If you have purify, and want to use it, run the make as `make PURIFY=purify'
-#PURIFY = @PURIFY@
-
-# Here is a rule for making .o files from .c files that does not
-# force the type of the machine (like -M_MACHINE) into the flags.
-.c.o:
- $(RM) $@
- $(CC) $(CCFLAGS) -c $<
-
-EXEEXT =
-OBJEXT = o
-
-# The name of this program and some version information.
-VERSPROG = rashversion$(EXEEXT)
-VERSOBJ = rashversion.$(OBJEXT)
-
-Program = rash$(EXEEXT)
-Version = 0.1
-PatchLevel = `$(BUILD_DIR)/$(VERSPROG) -p`
-RELSTATUS = release
-
-Machine = x86_64
-OS = linux-gnu
-VENDOR = pc
-MACHTYPE = x86_64-pc-linux-gnu
-
-# comment out for release
-DEBUG =
-MALLOC_DEBUG =
-
-THIS_SH = $(BUILD_DIR)/$(Program)
-
-# PROFILE_FLAGS is either -pg, to generate profiling info for use
-# with gprof, or nothing (the default).
-PROFILE_FLAGS=
-
-CFLAGS = -g -O2 -Wno-parentheses -Wno-format-security -Wl,--copy-dt-needed-entries
-CFLAGS_FOR_BUILD = -g -O2 -Wno-parentheses -Wno-format-security
-CPPFLAGS =
-CPPFLAGS_FOR_BUILD =
-LOCAL_CFLAGS = ${DEBUG} ${MALLOC_DEBUG}
-DEFS = -DHAVE_CONFIG_H
-LOCAL_DEFS = -DSHELL
-
-LOCALE_DEFS = -DLOCALEDIR='"$(localedir)"' -DPACKAGE='"$(PACKAGE)"'
-
-LOCAL_LIBS =
-
-LIBS = $(BUILTINS_LIB) $(LIBRARIES) -ldl -lrt -lpthread -L./target/debug -lralias -lrbind -lrbreak -lrbuiltin -lrcaller -lrcd -lrcolon -lrcommon -lcommand -lrcomplete -lrdeclare -lrecho -lrenable -lreval -lrexec -lrexit -lrfc -lrfg_bg -lrgetopts -lrhash -lrexit -lrhelp -lrhistory -lrjobs -lrkill -lrmapfile -lrpushd -lrread -lrlet -lrreturn -lrset -lrsetattr -lrshift -lrshopt -lrsource -lrsuspend -lrtest -lrtimes -lrtrap -lrtype -lrulimit -lrumask -lrwait -lrprintf -lrexec_cmd
-LIBS_FOR_BUILD =
-
-STATIC_LD =
-LOCAL_LDFLAGS = -rdynamic
-
-SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
-
-BASE_CCFLAGS = $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
- $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
-
-CCFLAGS = $(ADDON_CFLAGS) $(BASE_CCFLAGS) ${PROFILE_FLAGS} $(CPPFLAGS) $(CFLAGS) -Wl,--copy-dt-needed-entries
-
-CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
-
-BASE_LDFLAGS = $(LOCAL_LDFLAGS) $(CFLAGS)
-LDFLAGS = ${ADDON_LDFLAGS} ${BASE_LDFLAGS} ${PROFILE_FLAGS} ${STATIC_LD}
-LDFLAGS_FOR_BUILD = $(LDFLAGS) $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
-
-ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer
-ASAN_XLDFLAGS = -fsanitize=address
-
-GCOV_XCFLAGS = -fprofile-arcs -ftest-coverage
-GCOV_XLDFLAGS = -fprofile-arcs -ftest-coverage
-
-INCLUDES = -I. -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC)
-
-# Maybe add: -Wextra
-GCC_LINT_FLAGS = -O -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wno-parentheses \
- -Wcast-align -Wstrict-prototypes -Wconversion -Wformat \
- -Wformat-nonliteral -Wmissing-braces -Wuninitialized \
- -Wmissing-declarations -Winline \
- -Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic
-
-GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS)
-
-#
-# Support libraries
-#
-
-dot = .
-
-LIBSUBDIR = lib
-LIBSRC = $(srcdir)/$(LIBSUBDIR)
-
-LIBBUILD = ${BUILD_DIR}/${LIBSUBDIR}
-
-SUBDIR_INCLUDES = -I. -I$(topdir) -I$(topdir)/$(LIBSUBDIR)
-
-BUILD_INCLUDED_LIBINTL = no
-USE_INCLUDED_LIBINTL = no
-
-# the bash library
-# the library is a mix of functions that the C library does not provide on
-# some platforms and general shell utility functions
-SH_LIBSRC = $(LIBSRC)/sh
-SH_LIBDIR = $(dot)/${LIBSUBDIR}/sh
-SH_ABSSRC = ${topdir}/${SH_LIBSRC}
-
-SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
- ${SH_LIBSRC}/getenv.c ${SH_LIBSRC}/oslib.c \
- ${SH_LIBSRC}/setlinebuf.c ${SH_LIBSRC}/strchrnul.c \
- ${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strdup.c \
- ${SH_LIBSRC}/strerror.c \
- ${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
- ${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
- ${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c \
- ${SH_LIBSRC}/zread.c ${SH_LIBSRC}/zwrite.c \
- ${SH_LIBSRC}/shtty.c ${SH_LIBSRC}/inet_aton.c \
- ${SH_LIBSRC}/netopen.c ${SH_LIBSRC}/strpbrk.c \
- ${SH_LIBSRC}/timeval.c ${SH_LIBSRC}/clock.c \
- ${SH_LIBSRC}/makepath.c ${SH_LIBSRC}/pathcanon.c \
- ${SH_LIBSRC}/pathphys.c ${SH_LIBSRC}/stringlist.c \
- ${SH_LIBSRC}/stringvec.c ${SH_LIBSRC}/tmpfile.c \
- ${SH_LIBSRC}/spell.c ${SH_LIBSRC}/strtrans.c \
- ${SH_LIBSRC}/strcasestr.c ${SH_LIBSRC}/shquote.c \
- ${SH_LIBSRC}/snprintf.c ${SH_LIBSRC}/mailstat.c \
- ${SH_LIBSRC}/fmtulong.c ${SH_LIBSRC}/fmtullong.c \
- ${SH_LIBSRC}/strtoll.c ${SH_LIBSRC}/strtoull.c \
- ${SH_LIBSRC}/strtoimax.c ${SH_LIBSRC}/strtoumax.c \
- ${SH_LIBSRC}/fmtumax.c ${SH_LIBSRC}/netconn.c \
- ${SH_LIBSRC}/mktime.c ${SH_LIBSRC}/strftime.c \
- ${SH_LIBSRC}/memset.c ${SH_LIBSRC}/mbschr.c \
- ${SH_LIBSRC}/zcatfd.c ${SH_LIBSRC}/shmatch.c \
- ${SH_LIBSRC}/strnlen.c ${SH_LIBSRC}/winsize.c \
- ${SH_LIBSRC}/eaccess.c ${SH_LIBSRC}/wcsdup.c \
- ${SH_LIBSRC}/zmapfd.c ${SH_LIBSRC}/fpurge.c \
- ${SH_LIBSRC}/zgetline.c ${SH_LIBSRC}/mbscmp.c \
- ${SH_LIBSRC}/casemod.c ${SH_LIBSRC}/uconvert.c \
- ${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/dprintf.c \
- ${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \
- ${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \
- ${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \
- ${SH_LIBSRC}/shmbchar.c ${SH_LIBSRC}/utf8.c \
- ${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c
-
-SHLIB_LIB = -lsh
-SHLIB_LIBNAME = libsh.a
-SHLIB_LIBRARY = ${SH_LIBDIR}/${SHLIB_LIBNAME}
-SHLIB_LDFLAGS = -L${SH_LIBDIR}
-SHLIB_DEP = ${SHLIB_LIBRARY}
-
-# we assume for now that readline source is being shipped with bash
-RL_LIBSRC = $(LIBSRC)/readline
-RL_LIBDOC = $(RL_LIBSRC)/doc
-RL_LIBDIR = $(dot)/$(LIBSUBDIR)/readline
-RL_ABSSRC = ${topdir}/$(RL_LIBDIR)
-
-RL_INCLUDEDIR =
-
-READLINE_LIB = -lreadline
-READLINE_LIBRARY = $(RL_LIBDIR)/libreadline.a
-READLINE_LDFLAGS = -L${RL_LIBDIR}
-READLINE_DEP = $(READLINE_LIBRARY)
-
-# The source, object and documentation of the GNU Readline library.
-READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.h \
- $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/tcap.h \
- $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/keymaps.h \
- $(RL_LIBSRC)/history.h $(RL_LIBSRC)/histlib.h \
- $(RL_LIBSRC)/posixstat.h $(RL_LIBSRC)/tilde.h \
- $(RL_LIBSRC)/rlstdc.h ${RL_LIBSRC}/xmalloc.h \
- $(RL_LIBSRC)/rlshell.h ${RL_LIBSRC}/rlprivate.h \
- $(RL_LIBSRC)/colors.h $(RL_LIBSRC)/parse-colors.h \
- $(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
- $(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
- $(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
- $(RL_LIBSRC)/vi_mode.c $(RL_LIBSRC)/callback.c \
- $(RL_LIBSRC)/readline.c $(RL_LIBSRC)/tilde.c \
- $(RL_LIBSRC)/rltty.c $(RL_LIBSRC)/complete.c \
- $(RL_LIBSRC)/bind.c $(RL_LIBSRC)/isearch.c \
- $(RL_LIBSRC)/display.c $(RL_LIBSRC)/signals.c \
- $(RL_LIBSRC)/util.c $(RL_LIBSRC)/kill.c $(RL_LIBSRC)/text.c \
- $(RL_LIBSRC)/undo.c $(RL_LIBSRC)/macro.c \
- $(RL_LIBSRC)/terminal.c $(RL_LIBSRC)/nls.c \
- $(RL_LIBSRC)/input.c $(RL_LIBSRC)/xmalloc.c \
- $(RL_LIBSRC)/shell.c $(RL_LIBSRC)/savestring.c \
- $(RL_LIBSRC)/colors.c $(RL_LIBSRC)/parse-colors.c \
- $(RL_LIBSRC)/misc.c $(RL_LIBSRC)/mbutil.c $(RL_LIBSRC)/compat.c \
- $(RL_LIBSRC)/histexpand.c $(RL_LIBSRC)/history.c \
- $(RL_LIBSRC)/histsearch.c $(RL_LIBSRC)/histfile.c
-
-READLINE_OBJ = $(RL_LIBDIR)/readline.o $(RL_LIBDIR)/funmap.o \
- $(RL_LIBDIR)/parens.o $(RL_LIBDIR)/search.o \
- $(RL_LIBDIR)/keymaps.o $(RL_LIBDIR)/xmalloc.o \
- $(RL_LIBDIR)/rltty.o $(RL_LIBDIR)/complete.o \
- $(RL_LIBDIR)/bind.o $(RL_LIBDIR)/isearch.o \
- $(RL_LIBDIR)/display.o $(RL_LIBDIR)/signals.o \
- $(RL_LIBDIR)/tilde.o $(RL_LIBDIR)/util.o \
- $(RL_LIBDIR)/kill.o $(RL_LIBDIR)/undo.o $(RL_LIBDIR)/nls.o \
- $(RL_LIBDIR)/macro.o $(RL_LIBDIR)/input.o \
- $(RL_LIBDIR)/terminal.o $(RL_LIBDIR)/callback.o \
- $(RL_LIBDIR)/shell.o $(RL_LIBDIR)/savestring.o \
- $(RL_LIBDIR)/mbutil.o $(RL_LIBDIR)/compat.o \
- $(RL_LIBDIR)/history.o $(RL_LIBDIR)/histexpand.o \
- $(RL_LIBDIR)/histsearch.o $(RL_LIBDIR)/histfile.o \
- $(RL_LIBDIR)/colors.o $(RL_LIBDIR)/parse-colors.o
-
-HIST_LIBSRC = $(LIBSRC)/readline
-HIST_LIBDIR = $(dot)/$(LIBSUBDIR)/readline
-HIST_ABSSRC = ${topdir}/$(HIST_LIBDIR)
-
-HISTORY_LIB = -lhistory
-HISTORY_LIBRARY = $(HIST_LIBDIR)/libhistory.a
-HISTORY_LDFLAGS = -L$(HIST_LIBDIR)
-HISTORY_DEP = $(HISTORY_LIBRARY)
-
-# The source, object and documentation of the history library.
-HISTORY_SOURCE = $(HIST_LIBSRC)/history.c $(HIST_LIBSRC)/histexpand.c \
- $(HIST_LIBSRC)/histsearch.c $(HIST_LIBSRC)/histfile.c \
- $(HIST_LIBSRC)/shell.c \
- $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/histlib.h
-HISTORY_OBJ = $(HIST_LIBDIR)/history.o $(HIST_LIBDIR)/histexpand.o \
- $(HIST_LIBDIR)/histsearch.o $(HIST_LIBDIR)/histfile.o \
- $(HIST_LIBDIR)/shell.o
-
-# You only need termcap (or curses) if you are linking with GNU Readline.
-TERM_LIBSRC = $(LIBSRC)/termcap
-TERM_LIBDIR = $(dot)/$(LIBSUBDIR)/termcap
-TERM_ABSSRC = ${topdir}/$(TERM_LIBDIR)
-
-TERMCAP_LIB = -ltermcap
-TERMCAP_LIBRARY = $(TERM_LIBDIR)/libtermcap.a
-TERMCAP_LDFLAGS = -L$(TERM_LIBDIR)
-TERMCAP_DEP =
-
-TERMCAP_SOURCE = $(TERM_LIBSRC)/termcap.c $(TERM_LIBSRC)/tparam.c
-TERMCAP_OBJ = $(TERM_LIBDIR)/termcap.o $(TERM_LIBDIR)/tparam.o
-
-GLOB_LIBSRC = $(LIBSRC)/glob
-GLOB_LIBDIR = $(dot)/$(LIBSUBDIR)/glob
-GLOB_ABSSRC = ${topdir}/$(GLOB_LIBDIR)
-
-GLOB_LIB = -lglob
-GLOB_LIBRARY = $(GLOB_LIBDIR)/libglob.a
-GLOB_LDFLAGS = -L$(GLOB_LIBDIR)
-GLOB_DEP = $(GLOB_LIBRARY)
-
-GLOB_SOURCE = $(GLOB_LIBSRC)/glob.c $(GLOB_LIBSRC)/strmatch.c \
- $(GLOB_LIBSRC)/smatch.c $(GLOB_LIBSRC)/xmbsrtowcs.c \
- $(GLOB_LIBSRC)/glob_loop.c $(GLOB_LIBSRC)/sm_loop.c \
- $(GLOB_LIBSRC)/gmisc.c \
- $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
-GLOB_OBJ = $(GLOB_LIBDIR)/glob.o $(GLOB_LIBDIR)/strmatch.o \
- $(GLOB_LIBDIR)/smatch.o $(GLOB_LIBDIR)/xmbsrtowcs.o \
- $(GLOB_LIBDIR)/gmisc.o
-
-# The source, object and documentation for the GNU Tilde library.
-TILDE_LIBSRC = $(LIBSRC)/tilde
-TILDE_LIBDIR = $(dot)/$(LIBSUBDIR)/tilde
-TILDE_ABSSRC = ${topdir}/$(TILDE_LIBDIR)
-
-TILDE_LIB = -ltilde
-TILDE_LIBRARY = $(TILDE_LIBDIR)/libtilde.a
-TILDE_LDFLAGS = -L$(TILDE_LIBDIR)
-TILDE_DEP = $(TILDE_LIBRARY)
-
-TILDE_SOURCE = $(TILDE_LIBSRC)/tilde.c $(TILDE_LIBSRC)/tilde.h
-TILDE_OBJ = $(TILDE_LIBDIR)/tilde.o
-
-# libintl
-INTL_LIBSRC = $(LIBSRC)/intl
-INTL_LIBDIR = $(dot)/$(LIBSUBDIR)/intl
-INTL_ABSSRC = ${topdir}/$(INTL_LIB)
-INTL_BUILDDIR = ${LIBBUILD}/intl
-
-INTL_LIB =
-INTL_LIBRARY = $(INTL_LIBDIR)/libintl.a
-INTL_DEP =
-INTL_INC =
-
-LIBINTL_H =
-
-# libiconv
-LIBICONV =
-
-# tests
-LIBINTL =
-LTLIBINTL =
-INTLLIBS =
-INTLOBJS =
-
-# Our malloc.
-MALLOC_TARGET = malloc
-
-# set to alloca.o if we are using the C alloca in lib/malloc
-ALLOCA =
-
-ALLOC_LIBSRC = $(LIBSRC)/malloc
-ALLOC_LIBDIR = $(dot)/$(LIBSUBDIR)/malloc
-ALLOC_ABSSRC = ${topdir}/$(ALLOC_LIBDIR)
-
-MALLOC_SRC = malloc.c
-MALLOC_OTHERSRC = ${ALLOC_LIBSRC}/trace.c ${ALLOC_LIBSRC}/stats.c \
- ${ALLOC_LIBSRC}/table.c ${ALLOC_LIBSRC}/watch.c
-MALLOC_SOURCE = ${ALLOC_LIBSRC}/${MALLOC_SRC} ${MALLOC_OTHERSRC}
-MALLOC_CFLAGS = -DRCHECK -Dbotch=programming_error ${MALLOC_DEBUG}
-
-MALLOC_LIB = -lmalloc
-MALLOC_LIBRARY = $(ALLOC_LIBDIR)/libmalloc.a
-MALLOC_LDFLAGS = -L$(ALLOC_LIBDIR)
-MALLOC_DEP = $(MALLOC_LIBRARY)
-
-ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \
- $(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h \
- $(ALLOC_LIBSRC)/table.h $(ALLOC_LIBSRC)/watch.h
-
-$(MALLOC_LIBRARY): ${MALLOC_SOURCE} ${ALLOC_HEADERS} config.h
- @(cd $(ALLOC_LIBDIR) && \
- $(MAKE) $(MFLAGS) \
- MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1
-
-BASHINCDIR = ${srcdir}/include
-BASHINCFILES = $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/ansi_stdlib.h \
- $(BASHINCDIR)/filecntl.h $(BASHINCDIR)/posixdir.h \
- $(BASHINCDIR)/memalloc.h $(BASHINCDIR)/stdc.h \
- $(BASHINCDIR)/posixjmp.h $(BASHINCDIR)/posixwait.h \
- $(BASHINCDIR)/posixtime.h $(BASHINCDIR)/systimes.h \
- $(BASHINCDIR)/unionwait.h $(BASHINCDIR)/maxpath.h \
- $(BASHINCDIR)/shtty.h $(BASHINCDIR)/typemax.h \
- $(BASHINCDIR)/ocache.h
-
-LIBRARIES = $(GLOB_LIB) $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) \
- $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LIBICONV) $(LOCAL_LIBS)
-
-LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) \
- $(TILDE_DEP) $(MALLOC_DEP)
-
-LIBRARY_LDFLAGS = $(READLINE_LDFLAGS) $(HISTORY_LDFLAGS) $(GLOB_LDFLAGS) \
- $(TILDE_LDFLAGS) $(MALLOC_LDFLAGS) $(SHLIB_LDFLAGS)
-
-#
-# The shell itself
-#
-
-# The main source code for the Bourne Again SHell.
-CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
- dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \
- expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \
- test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
- input.c bashhist.c array.c arrayfunc.c assoc.c sig.c pathexp.c \
- unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
- list.c stringlib.c locale.c findcmd.c redir.c \
- pcomplete.c pcomplib.c syntax.c xmalloc.c
-
-HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
- general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
- quit.h unwind_prot.h syntax.h ${GRAM_H} \
- command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \
- subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
- array.h arrayfunc.h sig.h mailcheck.h bashintl.h bashjmp.h \
- execute_cmd.h parser.h pathexp.h pathnames.h pcomplete.h assoc.h \
- $(BASHINCFILES)
-
-SOURCES = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
-
-# headers in top-level source directory that get installed by install-headers
-INSTALLED_HEADERS = shell.h bashjmp.h command.h syntax.h general.h error.h \
- variables.h array.h assoc.h arrayfunc.h quit.h dispose_cmd.h \
- make_cmd.h subst.h sig.h externs.h builtins.h \
- bashtypes.h xmalloc.h config-top.h config-bot.h \
- bashintl.h bashansi.h bashjmp.h alias.h hashlib.h \
- conftypes.h unwind_prot.h jobs.h siglist.h
-INSTALLED_BUILTINS_HEADERS = bashgetopt.h common.h getopt.h
-INSTALLED_INCFILES = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \
- memalloc.h stdc.h posixjmp.h posixwait.h posixtime.h systimes.h \
- unionwait.h maxpath.h shtty.h typemax.h ocache.h chartypes.h gettext.h \
- posixstat.h shmbchar.h shmbutil.h stat-time.h
-
-# header files chosen based on running of configure
-SIGNAMES_H = lsignames.h
-
-# object files chosen based on running of configure
-JOBS_O = jobs.o
-SIGLIST_O =
-SIGNAMES_O =
-
-# Matching object files.
-OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
- dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
- expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
- trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
- alias.o array.o arrayfunc.o assoc.o braces.o bracecomp.o bashhist.o \
- bashline.o $(SIGLIST_O) list.o stringlib.o locale.o findcmd.o redir.o \
- pcomplete.o pcomplib.o syntax.o xmalloc.o $(SIGNAMES_O)
-
-# Where the source code of the shell builtins resides.
-BUILTIN_SRCDIR=$(srcdir)/builtins
-DEFSRC=$(BUILTIN_SRCDIR)
-BUILTIN_ABSSRC=${topdir}/builtins
-DEFDIR = $(dot)/builtins
-DEBUGGER_DIR = $(dot)/debugger
-
-BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \
- $(DEFSRC)/builtin.def $(DEFSRC)/cd.def $(DEFSRC)/colon.def \
- $(DEFSRC)/command.def ${DEFSRC}/complete.def \
- $(DEFSRC)/caller.def $(DEFSRC)/declare.def \
- $(DEFSRC)/echo.def $(DEFSRC)/enable.def $(DEFSRC)/eval.def \
- $(DEFSRC)/exec.def $(DEFSRC)/exit.def $(DEFSRC)/fc.def \
- $(DEFSRC)/fg_bg.def $(DEFSRC)/hash.def $(DEFSRC)/help.def \
- $(DEFSRC)/history.def $(DEFSRC)/jobs.def $(DEFSRC)/kill.def \
- $(DEFSRC)/let.def $(DEFSRC)/read.def $(DEFSRC)/return.def \
- $(DEFSRC)/set.def $(DEFSRC)/setattr.def $(DEFSRC)/shift.def \
- $(DEFSRC)/source.def $(DEFSRC)/suspend.def $(DEFSRC)/test.def \
- $(DEFSRC)/times.def $(DEFSRC)/trap.def $(DEFSRC)/type.def \
- $(DEFSRC)/ulimit.def $(DEFSRC)/umask.def $(DEFSRC)/wait.def \
- $(DEFSRC)/getopts.def $(DEFSRC)/reserved.def \
- $(DEFSRC)/pushd.def $(DEFSRC)/shopt.def $(DEFSRC)/printf.def \
- $(DEFSRC)/mapfile.def
-BUILTIN_C_SRC = $(DEFSRC)/mkbuiltins.c $(DEFSRC)/common.c \
- $(DEFSRC)/evalstring.c $(DEFSRC)/evalfile.c \
- $(DEFSRC)/bashgetopt.c $(GETOPT_SOURCE)
-BUILTIN_C_OBJ = $(DEFDIR)/common.o $(DEFDIR)/evalstring.o \
- $(DEFDIR)/evalfile.o $(DEFDIR)/bashgetopt.o
-BUILTIN_OBJS = $(DEFDIR)/alias.o $(DEFDIR)/bind.o $(DEFDIR)/break.o \
- $(DEFDIR)/builtin.o $(DEFDIR)/cd.o $(DEFDIR)/colon.o \
- $(DEFDIR)/command.o $(DEFDIR)/caller.o $(DEFDIR)/declare.o \
- $(DEFDIR)/echo.o $(DEFDIR)/enable.o $(DEFDIR)/eval.o \
- $(DEFDIR)/exec.o $(DEFDIR)/exit.o $(DEFDIR)/fc.o \
- $(DEFDIR)/fg_bg.o $(DEFDIR)/hash.o $(DEFDIR)/help.o \
- $(DEFDIR)/history.o $(DEFDIR)/jobs.o $(DEFDIR)/kill.o \
- $(DEFDIR)/let.o $(DEFDIR)/pushd.o $(DEFDIR)/read.o \
- $(DEFDIR)/return.o $(DEFDIR)/shopt.o $(DEFDIR)/printf.o \
- $(DEFDIR)/set.o $(DEFDIR)/setattr.o $(DEFDIR)/shift.o \
- $(DEFDIR)/source.o $(DEFDIR)/suspend.o $(DEFDIR)/test.o \
- $(DEFDIR)/times.o $(DEFDIR)/trap.o $(DEFDIR)/type.o \
- $(DEFDIR)/ulimit.o $(DEFDIR)/umask.o $(DEFDIR)/wait.o \
- $(DEFDIR)/getopts.o $(DEFDIR)/mapfile.o $(BUILTIN_C_OBJ)
-GETOPT_SOURCE = $(DEFSRC)/getopt.c $(DEFSRC)/getopt.h
-PSIZE_SOURCE = $(DEFSRC)/psize.sh $(DEFSRC)/psize.c
-
-BUILTINS_LIBRARY = $(DEFDIR)/libbuiltins.a
-BUILTINS_LIB = -lbuiltins
-BUILTINS_LDFLAGS = -L$(DEFDIR)
-BUILTINS_DEP = $(BUILTINS_LIBRARY)
-
-# Documentation for the shell.
-DOCSRC = $(srcdir)/doc
-DOCDIR = $(dot)/doc
-
-# Translations and other i18n support files
-PO_SRC = $(srcdir)/po/
-PO_DIR = $(dot)/po/
-
-SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
-
-SUPPORT_SRC = $(srcdir)/support/
-SDIR = $(dot)/support
-
-TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) xcase$(EXEEXT)
-CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
- tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \
- tests/printenv$(EXEEXT) xcase$(EXEEXT) tests/xcase$(EXEEXT) \
- mksignames$(EXEEXT) lsignames.h \
- mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \
- buildversion.o mksignames.o signames.o buildsignames.o
-CREATED_CONFIGURE = config.h config.cache config.status config.log \
- stamp-h po/POTFILES config.status.lineno
-CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
- lib/readline/Makefile lib/glob/Makefile \
- lib/sh/Makefile lib/tilde/Makefile lib/malloc/Makefile \
- lib/termcap/Makefile examples/loadables/Makefile \
- examples/loadables/Makefile.inc \
- examples/loadables/perl/Makefile support/Makefile \
- lib/intl/Makefile po/Makefile po/Makefile.in
-CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \
- ${DEFDIR}/builtext.h
-
-OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \
- $(srcdir)/RBASH $(srcdir)/README
-OTHER_INSTALLED_DOCS = CHANGES COMPAT NEWS POSIX RBASH README
-
-LOADABLES_DIR = ${top_builddir}/examples/loadables
-
-RUST_DIR = $(top_builddir)/builtins_rust
-#RUST_TARGET_LIB = $(top_builddir)/target/debug/librjobs.a $(top_builddir)/target/debug/librread.a
-RUST_BUILTINS_DIRS = $(RUST_DIR)/alias $(RUST_DIR)/bind $(RUST_DIR)/break_1 $(RUST_DIR)/builtin $(RUST_DIR)/caller $(RUST_DIR)/cd $(RUST_DIR)/colon $(RUST_DIR)/command $(RUST_DIR)/common $(RUST_DIR)/complete $(RUST_DIR)/declare $(RUST_DIR)/echo $(RUST_DIR)/enable $(RUST_DIR)/eval $(RUST_DIR)/exit $(RUST_DIR)/fc $(RUST_DIR)/fg_bg $(RUST_DIR)/getopts $(RUST_DIR)/hash $(RUST_DIR)/help $(RUST_DIR)/history $(RUST_DIR)/jobs $(RUST_DIR)/kill $(RUST_DIR)/mapfile $(RUST_DIR)/printf $(RUST_DIR)/pushd $(RUST_DIR)/read $(RUST_DIR)/rlet $(RUST_DIR)/rreturn $(RUST_DIR)/set $(RUST_DIR)/setattr $(RUST_DIR)/shift $(RUST_DIR)/shopt $(RUST_DIR)/source $(RUST_DIR)/suspend $(RUST_DIR)/test $(RUST_DIR)/times $(RUST_DIR)/trap $(RUST_DIR)/type $(RUST_DIR)/ulimit $(RUST_DIR)/umask $(RUST_DIR)/wait $(RUST_DIR)/exec $(RUST_DIR)/exec_cmd
-
-
-# Keep GNU Make from exporting the entire environment for small machines.
-.NOEXPORT:
-
-.made: $(Program) rashbug $(SDIR)/man2html$(EXEEXT)
- @echo "$(Program) last made for a $(Machine) running $(OS)" >.made
-
-$(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP) rust_builtins_lib
- $(RM) $@
- $(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
- ls -l $(Program)
- -$(SIZE) $(Program)
-
-.build: $(SOURCES) config.h Makefile version.h $(VERSPROG)
- @echo
- @echo " ***********************************************************"
- @echo " * *"
- @echo " * `$(BUILD_DIR)/$(VERSPROG) -l`"
- @echo " * *"
- @echo " ***********************************************************"
- @echo
-
-rust_builtins_lib:
- @for it in $(RUST_BUILTINS_DIRS); do cd $$it ; cargo build; cd -; done
-
-
-rashbug: $(SDIR)/rashbug.sh $(VERSPROG)
- @sed -e "s%!PATCHLEVEL!%$(PatchLevel)%" \
- $(SDIR)/rashbug.sh > $@
- @chmod a+rx rashbug
-
-strip: $(Program) .made
- $(STRIP) $(Program)
- ls -l $(Program)
- -$(SIZE) $(Program)
-
-lint:
- ${MAKE} ${MFLAGS} CFLAGS='${GCC_LINT_FLAGS}' .made
-
-asan:
- ${MAKE} ${MFLAGS} ADDON_CFLAGS='${ASAN_XCFLAGS}' ADDON_LDFLAGS='${ASAN_XLDFLAGS}' .made
-
-# cheating
-gcov:
- ${MAKE} ${MFLAGS} CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made
-
-
-# have to make this separate because making tests depend on $(PROGRAM)
-asan-tests: asan $(TESTS_SUPPORT)
- @-test -d tests || mkdir tests
- @cp $(TESTS_SUPPORT) tests
- @( cd $(srcdir)/tests && \
- BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
-
-profiling-tests: ${PROGRAM}
- @test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be built with profiling enabled" >&2; exit 1; }
- @${MAKE} ${MFLAGS} tests TESTSCRIPT=run-gprof
-
-version.h: $(SOURCES) config.h Makefile patchlevel.h
- $(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
- && mv newversion.h version.h
-
-rashversion$(EXEEXT): buildversion.o $(SUPPORT_SRC)rashversion.c
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)rashversion.c buildversion.o ${LIBS_FOR_BUILD}
-
-buildversion.o: $(srcdir)/version.c
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c -o $@ $(srcdir)/version.c
-
-buildversion.o: bashintl.h $(BASHINCDIR)/gettext.h
-buildversion.o: version.h patchlevel.h conftypes.h
-
-# old rules
-GRAM_H = parser-built
-y.tab.o: y.tab.h y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
-${GRAM_H}: y.tab.h
- @-if test -f y.tab.h ; then \
- cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \
- fi
-
-y.tab.c: parse.y
-# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
- $(YACC) -d $(srcdir)/parse.y
- touch parser-built
-# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
-
-y.tab.h: y.tab.c
- @true
-
-
-# Subdirs will often times want version.h, so they'll change back up to
-# the top level and try to create it. This causes parallel build issues
-# so just force top level sanity before we descend.
-$(LIBDEP): .build
-#$(LIBDEP): version.h
-
-$(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
- @echo making $@ in ${RL_LIBDIR}
- @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \
- cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libreadline.a) || exit 1
-
-$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(READLINE_DEP)
- @echo making $@ in ${HIST_LIBDIR}
- @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \
- cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libhistory.a) || exit 1
-
-$(GLOB_LIBRARY): config.h $(GLOB_SOURCE)
- @echo making $@ in ${GLOB_LIBDIR}
- @(cd ${GLOB_LIBDIR} && \
- $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libglob.a) || exit 1
-
-$(TILDE_LIBRARY): config.h $(TILDE_SOURCE)
- @echo making $@ in ${TILDE_LIBDIR}
- @(cd ${TILDE_LIBDIR} && \
- $(MAKE) $(MFLAGS) libtilde.a) || exit 1
-
-$(TERMCAP_LIBRARY): config.h ${TERMCAP_SOURCE}
- @echo making $@ in ${TERM_LIBDIR}
- @(cd ${TERM_LIBDIR} && \
- $(MAKE) $(MFLAGS) libtermcap.a) || exit 1
-
-$(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
- @echo making $@ in ${SH_LIBDIR}
- @(cd ${SH_LIBDIR} && \
- $(MAKE) $(MFLAGS) DEBUG=${DEBUG} ${SHLIB_LIBNAME}) || exit 1
-
-${INTL_LIBRARY}: config.h ${INTL_LIBDIR}/Makefile
- @echo making $@ in ${INTL_LIBDIR}
- @(cd ${INTL_LIBDIR} && \
- $(MAKE) $(MFLAGS) XCFLAGS="${LOCAL_CFLAGS}" all) || exit 1
-
-${LIBINTL_H}: ${INTL_DEP}
-
-signames.o: $(SUPPORT_SRC)signames.c
- $(RM) $@
- $(CC) $(CCFLAGS) -c $(SUPPORT_SRC)signames.c
-
-buildsignames.o: $(SUPPORT_SRC)signames.c
- $(RM) $@
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -o $@ -c $(SUPPORT_SRC)signames.c
-
-mksignames.o: $(SUPPORT_SRC)mksignames.c
- $(RM) $@
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) -DBUILDTOOL -c $(SUPPORT_SRC)mksignames.c
-
-mksignames$(EXEEXT): mksignames.o buildsignames.o
- $(RM) $@
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ mksignames.o buildsignames.o ${LIBS_FOR_BUILD}
-
-mksyntax$(EXEEXT): ${srcdir}/mksyntax.c config.h syntax.h ${BASHINCDIR}/chartypes.h bashansi.h
- $(RM) $@
- ${CC_FOR_BUILD} ${CCFLAGS_FOR_BUILD} ${LDFLAGS_FOR_BUILD} -o $@ ${srcdir}/mksyntax.c ${LIBS_FOR_BUILD}
-
-# make a list of signals for the local system -- this is done when we're
-# *not* cross-compiling
-lsignames.h: mksignames$(EXEEXT)
- $(RM) $@
- ./mksignames$(EXEEXT) $@
-
-# copy the correct signames header file to signames.h
-signames.h: $(SIGNAMES_H)
- -if cmp -s $(SIGNAMES_H) $@ ; then :; else $(RM) $@ ; $(CP) $(SIGNAMES_H) $@ ; fi
-
-syntax.c: mksyntax${EXEEXT} $(srcdir)/syntax.h
- $(RM) $@
- ./mksyntax$(EXEEXT) -o $@
-
-$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h $(DEFDIR)/builtext.h version.h
- @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} targets ) || exit 1
-
-# these require special rules to circumvent make builtin rules
-${DEFDIR}/common.o: $(BUILTIN_SRCDIR)/common.c
- @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} common.o) || exit 1
-
-${DEFDIR}/bashgetopt.o: $(BUILTIN_SRCDIR)/bashgetopt.c
- @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} bashgetopt.o) || exit 1
-
-${DEFDIR}/builtext.h: $(BUILTIN_DEFS)
- @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) builtext.h ) || exit 1
-
-${DEFDIR}/pipesize.h:
- @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) pipesize.h ) || exit 1
-
-$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c
- @(cd $(SDIR) && $(MAKE) $(MFLAGS) all ) || exit 1
-
-# For the justification of the following Makefile rules, see node
-# `Automatic Remaking' in GNU Autoconf documentation.
-
-Makefile makefile: config.status $(srcdir)/Makefile.in
- CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
-
-Makefiles makefiles: config.status $(srcdir)/Makefile.in
- @for mf in $(CREATED_MAKEFILES); do \
- CONFIG_FILES=$$mf CONFIG_HEADERS= $(SHELL) ./config.status || exit 1; \
- done
-
-config.h: stamp-h
-
-stamp-h: config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/config-bot.h
- CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status
-
-config.status: $(srcdir)/configure
- $(SHELL) ./config.status --recheck
-
-pathnames.h: Makefile $(srcdir)/pathnames.h.in
- @sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' $(srcdir)/pathnames.h.in > pathnames.tmp
- @if test -f $@; then \
- cmp -s pathnames.tmp $@ || mv pathnames.tmp $@; \
- else \
- mv pathnames.tmp $@; \
- fi
- @${RM} pathnames.tmp
-
-# comment out for distribution
-$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
- cd $(srcdir) && autoconf
-
-# for chet
-reconfig: force
- sh $(srcdir)/configure -C
-
-loadables:
- cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) all
-
-#newversion: mkversion
-# $(RM) .build
-# ./mkversion -dir $(srcdir) -dist
-# mv -f newversion.h version.h
-# $(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir)
-
-doc documentation: force
- @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) )
-
-info dvi ps: force
- @(cd $(DOCDIR) ; $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)' $@ )
-
-force:
-
-# unused
-TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
- etags $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
-
-tags: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE)
- ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@
-
-# Targets that actually do things not part of the build
-
-installdirs:
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(bindir)
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(man1dir)
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(infodir)
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(docdir)
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-
-install: .made installdirs
- $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program)
- $(INSTALL_SCRIPT) $(INSTALLMODE2) rashbug $(DESTDIR)$(bindir)/rashbug
- $(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
- -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
- man1dir=$(man1dir) man1ext=$(man1ext) \
- man3dir=$(man3dir) man3ext=$(man3ext) \
- infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
- -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-
-install-strip:
- $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
- prefix=${prefix} exec_prefix=${exec_prefix} \
- DESTDIR=$(DESTDIR) install
-
-install-headers-dirs:
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/builtins
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/include
- @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(pkgconfigdir)
-
-install-headers: install-headers-dirs
- @for hf in $(INSTALLED_HEADERS) ; do \
- ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
- done
- @for hf in $(INSTALLED_INCFILES) ; do \
- ${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf || exit 1; \
- done
- @for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \
- ${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf || exit 1; \
- done
- @for hf in $(CREATED_HEADERS) ; do \
- if test -f $(BUILD_DIR)/"$$hf" ; then \
- ${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
- else \
- ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf || exit 1; \
- fi ; \
- done
- -$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc
-
-uninstall-headers:
- -( cd $(DESTDIR)$(headersdir) && $(RM) $(INSTALLED_HEADERS) )
- -( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCFILES) )
- -( cd $(DESTDIR)$(headersdir)/builtins && $(RM) $(INSTALLED_BUILTINS_HEADERS) )
- -( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) )
- -( $(RM) $(DESTDIR)$(pkgconfigdir)/bash.pc )
-
-uninstall: .made
- $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/rashbug
- -( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} )
- -( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
- man1dir=$(man1dir) man1ext=$(man1ext) \
- man3dir=$(man3dir) man3ext=$(man3ext) \
- infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ )
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-
-.PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean maybe-clean
-
-LIB_SUBDIRS = ${RL_LIBDIR} ${HIST_LIBDIR} ${TERM_LIBDIR} ${GLOB_LIBDIR} \
- ${INTL_LIBDIR} ${TILDE_LIBDIR} ${ALLOC_LIBDIR} ${SH_LIBDIR}
-
-basic-clean:
- $(RM) $(OBJECTS) $(Program) rashbug
- $(RM) .build .made version.h
- cargo clean
-
-clean: basic-clean
- ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
- ( cd builtins && $(MAKE) $(MFLAGS) $@ )
- -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
- -for libdir in ${LIB_SUBDIRS}; do \
- (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
- done
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- $(RM) $(CREATED_SUPPORT)
- cargo clean
-
-mostlyclean: basic-clean
- ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
- ( cd builtins && $(MAKE) $(MFLAGS) $@ )
- -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
- -for libdir in ${LIB_SUBDIRS}; do \
- (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
- done
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
-
-distclean: basic-clean maybe-clean
- ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
- ( cd builtins && $(MAKE) $(MFLAGS) $@ )
- -( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
- -for libdir in ${LIB_SUBDIRS}; do \
- (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
- done
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- $(RM) $(CREATED_CONFIGURE) tags TAGS
- $(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h
-
-maintainer-clean: basic-clean
- @echo This command is intended for maintainers to use.
- @echo It deletes files that may require special tools to rebuild.
- $(RM) y.tab.c y.tab.h parser-built tags TAGS
- ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
- ( cd builtins && $(MAKE) $(MFLAGS) $@ )
- ( cd $(SDIR) && $(MAKE) $(MFLAGS) $@ )
- -for libdir in ${LIB_SUBDIRS}; do \
- (cd $$libdir && test -f Makefile && $(MAKE) $(MFLAGS) $@) ;\
- done
- -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
- $(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
- $(RM) $(CREATED_SUPPORT) Makefile pathnames.h
-
-maybe-clean:
- -if test X"`cd $(topdir) && pwd -P`" != X"`cd $(BUILD_DIR) && pwd -P`" ; then \
- $(RM) parser-built y.tab.c y.tab.h ; \
- fi
-
-recho$(EXEEXT): $(SUPPORT_SRC)recho.c
- @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD}
-
-zecho$(EXEEXT): $(SUPPORT_SRC)zecho.c
- @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD}
-
-printenv$(EXEEXT): $(SUPPORT_SRC)printenv.c
- @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD}
-
-xcase$(EXEEXT): $(SUPPORT_SRC)xcase.c
- @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)xcase.c ${LIBS_FOR_BUILD}
-
-test tests check: force $(Program) $(TESTS_SUPPORT)
- @-test -d tests || mkdir tests
- @cp $(TESTS_SUPPORT) tests
- @( cd $(srcdir)/tests && \
- BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
-
-symlinks:
- $(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
-
-dist: force
- @echo Bash distributions are created using $(srcdir)/support/mkdist.
- @echo Here is a sample of the necessary commands:
- @echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${PACKAGE} -t $(PACKAGE_VERSION)
-
-xdist: force
- ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
- ( cd po && $(MAKE) $(MFLAGS) $@ )
-
-depend: depends
-
-depends: force
- $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES}
-
-#### PRIVATE TARGETS ####
-hashtest: hashlib.c
- $(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB) $(MALLOC_LIBRARY)
-
-############################ DEPENDENCIES ###############################
-
-# Files that depend on the definitions in config-top.h, which are not meant
-# to be changed
-array.o: $(srcdir)/config-top.h
-bashhist.o: $(srcdir)/config-top.h
-shell.o: $(srcdir)/config-top.h
-input.o: $(srcdir)/config-top.h
-y.tab.o: $(srcdir)/config-top.h
-jobs.o: $(srcdir)/config-top.h
-nojobs.o: $(srcdir)/config-top.h
-execute_cmd.o: $(srcdir)/config-top.h
-variables.o: $(srcdir)/config-top.h
-findcmd.o: $(srcdir)/config-top.h
-subst.o: $(srcdir)/config-top.h
-builtins/cd.o: $(srcdir)/config-top.h
-builtins/command.o: $(srcdir)/config-top.h
-builtins/common.o: $(srcdir)/config-top.h
-builtins/declare.o: $(srcdir)/config-top.h
-builtins/break.o: $(srcdir)/config-top.h
-builtins/echo.o: $(srcdir)/config-top.h
-builtins/evalstring.o: $(srcdir)/config-top.h
-builtins/exit.o: $(srcdir)/config-top.h
-builtins/kill.o: $(srcdir)/config-top.h
-builtins/shopt.o: $(srcdir)/config-top.h
-
-# XXX
-${SH_LIBDIR}/tmpfile.o: $(srcdir)/config-top.h
-
-# shell basics
-copy_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-copy_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-copy_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-copy_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-copy_cmd.o: bashansi.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
-dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-dispose_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
-dispose_cmd.o: error.h general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-dispose_cmd.o: ${BASHINCDIR}/ocache.h
-dispose_cmd.o: assoc.h ${BASHINCDIR}/chartypes.h
-error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
-error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
-error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-error.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
-error.o: input.h execute_cmd.h
-error.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h assoc.h
-eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
-eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-eval.o: input.h execute_cmd.h
-eval.o: bashhist.h assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h
-execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
-execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
-execute_cmd.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/chartypes.h
-execute_cmd.o: $(DEFSRC)/getopt.h
-execute_cmd.o: bashhist.h input.h ${GRAM_H} assoc.h hashcmd.h alias.h
-execute_cmd.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/posixwait.h
-expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h execute_cmd.h
-expr.o: ${BASHINCDIR}/chartypes.h
-expr.o: assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/typemax.h
-findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
-findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
-findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
-findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
-findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h execute_cmd.h
-findcmd.o: ${BASHINCDIR}/chartypes.h
-flags.o: config.h flags.h
-flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h execute_cmd.h
-flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h
-flags.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashansi.h assoc.h
-general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-general.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h parser.h
-general.o: pathexp.h
-general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
-general.o: ${BASHINCDIR}/chartypes.h
-general.o: trap.h input.h assoc.h test.h findcmd.h
-general.o: ${BASHINCDIR}/ocache.h $(DEFSRC)/common.h
-hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
-hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h pathnames.h hashlib.h
-hashcmd.o: quit.h sig.h flags.h
-hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-hashlib.o: assoc.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h
-input.o: quit.h shell.h pathnames.h
-list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-list.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-list.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashansi.h assoc.h
-locale.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-locale.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-locale.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-locale.o: ${BASHINCDIR}/chartypes.h
-locale.o: input.h assoc.h ${BASHINCDIR}/ocache.h
-mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-mailcheck.o: ${BASHINCDIR}/posixtime.h
-mailcheck.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-mailcheck.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-mailcheck.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-mailcheck.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-mailcheck.o: execute_cmd.h mailcheck.h
-mailcheck.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h
-make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
-make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h make_cmd.h
-make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
-make_cmd.o: jobs.h quit.h sig.h siglist.h syntax.h dispose_cmd.h parser.h
-make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/ocache.h
-make_cmd.o: shell.h execute_cmd.h pathnames.h
-make_cmd.o: $(BASHINCDIR)/maxpath.h make_cmd.c assoc.h $(BASHINCDIR)/chartypes.h
-make_cmd.o: unwind_prot.h $(BASHINCDIR)/posixjmp.h bashjmp.h $(BASHINCDIR)/posixwait.h
-y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
-y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h execute_cmd.o
-y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
-y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
-y.tab.o: ${BASHINCDIR}/typemax.h assoc.h ${BASHINCDIR}/ocache.h
-y.tab.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/posixwait.h
-pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-pathexp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-pathexp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-pathexp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-pathexp.o: pathexp.h flags.h
-pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/strmatch.h
-pathexp.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-pathexp.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h
-print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-print_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-print_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-print_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
-print_cmd.o: flags.h input.h assoc.h
-print_cmd.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
-redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
-redir.o: ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-redir.o: general.h xmalloc.h variables.h arrayfunc.h conftypes.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
-redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
-redir.o: flags.h execute_cmd.h redir.h input.h
-redir.o: ${DEFDIR}/pipesize.h
-redir.o: trap.h assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
-shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
-shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
-shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h
-shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/posixwait.h
-shell.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h assoc.h alias.h
-sig.o: config.h bashtypes.h
-sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
-sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
-sig.o: ${DEFDIR}/builtext.h
-siglist.o: config.h bashtypes.h siglist.h trap.h
-stringlib.o: bashtypes.h ${BASHINCDIR}/chartypes.h
-stringlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-stringlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-stringlib.o: bashansi.h pathexp.h assoc.h $(BASHINCDIR)/ocache.h
-stringlib.o: ${GLOB_LIBSRC}/glob.h ${GLOB_LIBSRC}/strmatch.h
-subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
-subst.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-subst.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-subst.o: flags.h jobs.h siglist.h execute_cmd.h ${BASHINCDIR}/filecntl.h trap.h pathexp.h
-subst.o: mailcheck.h input.h $(DEFSRC)/getopt.h $(DEFSRC)/common.h
-subst.o: bashline.h bashhist.h ${GLOB_LIBSRC}/strmatch.h
-subst.o: ${BASHINCDIR}/chartypes.h
-subst.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-subst.o: ${DEFDIR}/builtext.h
-test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
-test.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-test.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-test.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-test.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
-test.o: ${BASHINCDIR}/stat-time.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-test.o: $(GLOB_LIBSRC)/strmatch.h bashansi.h pathexp.h assoc.h
-test.o: ${DEFSRC}/common.h
-trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
-trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
-trap.o: signames.h $(DEFSRC)/common.h
-trap.o: ${DEFDIR}/builtext.h jobs.h
-unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
-unwind_prot.o: general.h xmalloc.h unwind_prot.h quit.h sig.h
-unwind_prot.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h error.h
-variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
-variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h
-variables.o: pcomplete.h ${BASHINCDIR}/chartypes.h
-variables.o: ${BASHINCDIR}/posixtime.h assoc.h ${DEFSRC}/getopt.h
-variables.o: version.h $(DEFDIR)/builtext.h
-version.o: conftypes.h patchlevel.h version.h
-xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
-xmalloc.o: ${BASHINCDIR}/stdc.h $(ALLOC_LIBSRC)/shmalloc.h
-
-# job control
-
-jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
-jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h assoc.h
-jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
-jobs.o: execute_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
-jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
-jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
-jobs.o: ${BASHINCDIR}/posixtime.h
-jobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h
-nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
-nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h
-nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h parser.h
-nojobs.o: $(DEFDIR)/builtext.h
-nojobs.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h $(BASHINCDIR)/typemax.h
-
-# shell features that may be compiled in
-
-array.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-array.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-array.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-array.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-array.o: $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
-array.o: $(DEFSRC)/common.h
-arrayfunc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h pathexp.h
-arrayfunc.o: execute_cmd.h
-arrayfunc.o: assoc.h $(BASHINCDIR)/ocache.h $(BASHINCDIR)/chartypes.h
-arrayfunc.o: $(DEFSRC)/common.h
-arrayfunc.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-assoc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
-assoc.o: command.h ${BASHINCDIR}/stdc.h error.h
-assoc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
-assoc.o: assoc.h hashlib.h
-assoc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-assoc.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-assoc.o: array.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-assoc.o: $(DEFSRC)/common.h
-braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-braces.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-braces.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-braces.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-braces.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-braces.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-braces.o: ${BASHINCDIR}/typemax.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
-alias.o: general.h xmalloc.h bashtypes.h externs.h alias.h
-alias.o: pcomplete.h hashlib.h
-alias.o: ${BASHINCDIR}/chartypes.h
-
-pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
-pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
-pcomplib.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
-pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
-pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h assoc.h array.h
-pcomplib.o: ${BASHINCDIR}/posixjmp.h ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h
-
-pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
-pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h syntax.h
-pcomplete.o: bashjmp.h command.h general.h xmalloc.h error.h variables.h arrayfunc.h conftypes.h quit.h
-pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
-pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h execute_cmd.h
-pcomplete.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-pcomplete.o: ${DEFDIR}/builtext.h
-
-# library support files
-
-bashhist.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
-bashhist.o: ${BASHINCDIR}/filecntl.h
-bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
-bashhist.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashhist.h assoc.h
-bashhist.o: $(GLOB_LIBSRC)/strmatch.h ${GLOB_LIBSRC}/glob.h
-bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
-bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
-bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h
-bashline.o: trap.h flags.h assoc.h $(BASHINCDIR)/ocache.h
-bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
-bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
-bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-bashline.o: ${DEFDIR}/builtext.h
-bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h
-bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h
-bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h
-bracecomp.o: array.h hashlib.h alias.h builtins.h
-bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-bracecomp.o: ${BASHINCDIR}/ocache.h ${BASHINCDIR}/chartypes.h bashhist.h assoc.h
-bracecomp.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-
-# library dependencies
-
-bashhist.o: $(RL_LIBSRC)/rltypedefs.h
-bashline.o: $(RL_LIBSRC)/rlconf.h
-bashline.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
-bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
-bashline.o: $(RL_LIBSRC)/rltypedefs.h ${RL_LIBSRC}/rlmbutil.h
-bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-bracecomp.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-bracecomp.o: $(RL_LIBSRC)/rltypedefs.h
-y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-y.tab.o: $(RL_LIBSRC)/rltypedefs.h
-subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-shell.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-shell.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-shell.o: $(RL_LIBSRC)/rltypedefs.h
-variables.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-variables.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-variables.o: $(RL_LIBSRC)/rltypedefs.h
-jobs.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
-jobs.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
-jobs.o: $(RL_LIBSRC)/rltypedefs.h
-
-shell.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-variables.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
-
-bashline.o: $(TILDE_LIBSRC)/tilde.h
-bracecomp.o: $(TILDE_LIBSRC)/tilde.h
-execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
-general.o: $(TILDE_LIBSRC)/tilde.h
-mailcheck.o: $(TILDE_LIBSRC)/tilde.h
-shell.o: $(TILDE_LIBSRC)/tilde.h
-subst.o: $(TILDE_LIBSRC)/tilde.h
-variables.o: $(TILDE_LIBSRC)/tilde.h
-jobs.o: $(TILDE_LIBSRC)/tilde.h
-y.tab.o: $(TILDE_LIBSRC)/tilde.h
-
-# libintl dependencies
-arrayfunc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-bashhist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-bashline.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-braces.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-error.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-eval.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-execute_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-expr.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-general.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-input.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-jobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-locale.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-mailcheck.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-make_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-nojobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-y.tab.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-pathexp.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-pcomplete.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-pcomplib.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-print_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-redir.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-shell.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-sig.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-siglist.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-subst.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-test.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-trap.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-variables.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-version.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-xmalloc.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-
-# XXX
-$(MALLOC_SOURCE): bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-
-signames.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-
-# XXX - dependencies checked through here
-
-# builtin c sources
-builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/bashgetopt.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
-builtins/bashgetopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-builtins/bashgetopt.o: $(DEFSRC)/common.h
-builtins/bashgetopt.o: ${BASHINCDIR}/chartypes.h
-builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/common.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
-builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h siglist.h
-builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
-builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h
-builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h
-builtins/common.o: ${DEFDIR}/builtext.h parser.h
-builtins/common.o: ${BASHINCDIR}/chartypes.h
-builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
-builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
-builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
-builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
-builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/evalstring.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
-builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h input.h
-builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
-builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
-builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
-builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h
-builtins/evalstring.o: ${DEFDIR}/builtext.h
-builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
-builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h
-builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
-builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-builtins/getopt.o: $(DEFSRC)/getopt.h
-builtins/mkbuiltins.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
-builtins/mkbuiltins.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/mkbuiltins.o: $(BASHINCDIR)/stdc.h
-
-# builtin def files
-builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/alias.o: quit.h $(DEFSRC)/common.h pathnames.h
-builtins/alias.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
-builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h arrayfunc.h conftypes.h
-builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/bind.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/bind.o: $(DEFSRC)/bashgetopt.h pathnames.h
-builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/break.o: pathnames.h execute_cmd.h
-builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
-builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/builtin.o: pathnames.h execute_cmd.h
-builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/caller.o: $(DEFSRC)/common.h quit.h
-builtins/caller.o: ${BASHINCDIR}/chartypes.h bashtypes.h
-builtins/caller.o: ${DEFDIR}/builtext.h pathnames.h
-builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/cd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/cd.o: $(DEFSRC)/common.h quit.h pathnames.h
-builtins/colon.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/colon.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/colon.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/colon.o: pathnames.h
-builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
-builtins/command.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h pathnames.h
-builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/declare.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/declare.o: $(DEFSRC)/bashgetopt.h pathnames.h flags.h
-builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/echo.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/echo.o: pathnames.h
-builtins/echo.o: $(DEFSRC)/common.h
-builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/enable.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/enable.o: pcomplete.h pathnames.h
-builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/eval.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/eval.o: pathnames.h
-builtins/exec.o: bashtypes.h pathnames.h
-builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/exec.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/exec.o: dispose_cmd.h make_cmd.h subst.h externs.h execute_cmd.h
-builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h
-builtins/exec.o: pathnames.h
-builtins/exit.o: bashtypes.h
-builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/exit.o: pathnames.h execute_cmd.h
-builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
-builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h
-builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
-builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h
-builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h parser.h
-builtins/fc.o: ${BASHINCDIR}/chartypes.h
-builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h
-builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/fg_bg.o: pathnames.h execute_cmd.h
-builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/getopts.o: pathnames.h execute_cmd.h
-builtins/hash.o: bashtypes.h execute_cmd.h
-builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
-builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/hash.o: pathnames.h
-builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h
-builtins/help.o: conftypes.h quit.h execute_cmd.h
-builtins/help.o: $(GLOB_LIBSRC)/glob.h pathnames.h
-builtins/history.o: bashtypes.h pathnames.h parser.h
-builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
-builtins/history.o: bashhist.h variables.h arrayfunc.h conftypes.h
-builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/inlib.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
-builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/inlib.o: pathnames.h
-builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
-builtins/jobs.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/jobs.o: pathnames.h
-builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/kill.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/kill.o: pathnames.h
-builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/let.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/let.o: pathnames.h
-builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
-builtins/printf.o: general.h xmalloc.h quit.h dispose_cmd.h make_cmd.h subst.h
-builtins/printf.o: externs.h sig.h pathnames.h shell.h syntax.h unwind_prot.h
-builtins/printf.o: variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
-builtins/printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-builtins/printf.o: ${BASHINCDIR}/chartypes.h
-builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/pushd.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/pushd.o: $(DEFSRC)/common.h pathnames.h
-builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/read.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-builtins/read.o: pathnames.h
-builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/return.o: pathnames.h execute_cmd.h
-builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h
-builtins/set.o: pathnames.h parser.h
-builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
-builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/setattr.o: pathnames.h flags.h execute_cmd.h
-builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/shift.o: pathnames.h
-builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h
-builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
-builtins/shopt.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h arrayfunc.h conftypes.h ${BASHINCDIR}/maxpath.h
-builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h pathnames.h
-builtins/shopt.o: bashhist.h bashline.h
-builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h
-builtins/source.o: pathnames.h execute_cmd.h
-builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/suspend.o: pathnames.h
-builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/test.o: execute_cmd.h test.h pathnames.h
-builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/times.o: pathnames.h
-builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/trap.o: quit.h $(DEFSRC)/common.h
-builtins/trap.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/trap.o: pathnames.h
-builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
-builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/type.o: pathnames.h execute_cmd.h parser.h
-builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/ulimit.o: pathnames.h
-builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/umask.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/umask.o: ${BASHINCDIR}/chartypes.h pathnames.h
-builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/wait.o: execute_cmd.h
-builtins/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h
-
-builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
-builtins/complete.o: unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-builtins/complete.o: builtins.h pathnames.h general.h
-builtins/complete.o: bashtypes.h ${BASHINCDIR}/chartypes.h xmalloc.h
-builtins/complete.o: pcomplete.h
-builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h
-builtins/mapfile.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
-builtins/mapfile.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
-builtins/mapfile.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
-builtins/mapfile.o: pathnames.h
-
-# libintl dependencies
-builtins/bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-builtins/umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-
-# builtin library dependencies
-builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
-builtins/bind.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/rlstdc.h
-
-builtins/bind.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
-builtins/fc.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
-builtins/history.o: $(HIST_LIBSRC)/history.h $(RL_LIBSRC)/rlstdc.h
-
-builtins/common.o: $(TILDE_LIBSRC)/tilde.h
-builtins/cd.o: $(TILDE_LIBSRC)/tilde.h
-
-builtins/alias.o: $(DEFSRC)/alias.def
-builtins/bind.o: $(DEFSRC)/bind.def
-builtins/break.o: $(DEFSRC)/break.def
-builtins/builtin.o: $(DEFSRC)/builtin.def
-builtins/caller.o: $(DEFSRC)/caller.def
-builtins/cd.o: $(DEFSRC)/cd.def
-builtins/colon.o: $(DEFSRC)/colon.def
-builtins/command.o: $(DEFSRC)/command.def
-builtins/complete.o: $(DEFSRC)/complete.def
-builtins/declare.o: $(DEFSRC)/declare.def
-builtins/echo.o: $(DEFSRC)/echo.def
-builtins/enable.o: $(DEFSRC)/enable.def
-builtins/eval.o: $(DEFSRC)/eval.def
-builtins/exec.o: $(DEFSRC)/exec.def
-builtins/exit.o: $(DEFSRC)/exit.def
-builtins/fc.o: $(DEFSRC)/fc.def
-builtins/fg_bg.o: $(DEFSRC)/fg_bg.def
-builtins/getopts.o: $(DEFSRC)/getopts.def
-builtins/hash.o: $(DEFSRC)/hash.def
-builtins/help.o: $(DEFSRC)/help.def
-builtins/history.o: $(DEFSRC)/history.def
-builtins/inlib.o: $(DEFSRC)/inlib.def
-builtins/jobs.o: $(DEFSRC)/jobs.def
-builtins/kill.o: $(DEFSRC)/kill.def
-builtins/let.o: $(DEFSRC)/let.def
-builtins/mapfile.o: $(DEFSRC)/mapfile.def
-builtins/pushd.o: $(DEFSRC)/pushd.def
-builtins/read.o: $(DEFSRC)/read.def
-builtins/reserved.o: $(DEFSRC)/reserved.def
-builtins/return.o: $(DEFSRC)/return.def
-builtins/set.o: $(DEFSRC)/set.def
-builtins/setattr.o: $(DEFSRC)/setattr.def
-builtins/shift.o: $(DEFSRC)/shift.def
-builtins/shopt.o: $(DEFSRC)/shopt.def
-builtins/source.o: $(DEFSRC)/source.def
-builtins/suspend.o: $(DEFSRC)/suspend.def
-builtins/test.o: $(DEFSRC)/test.def
-builtins/times.o: $(DEFSRC)/times.def
-builtins/trap.o: $(DEFSRC)/trap.def
-builtins/type.o: $(DEFSRC)/type.def
-builtins/ulimit.o: $(DEFSRC)/ulimit.def
-builtins/umask.o: $(DEFSRC)/umask.def
-builtins/wait.o: $(DEFSRC)/wait.def
diff --git a/bash-5.1/bashhist.c b/bash-5.1/bashhist.c
index 4c0247235b64385ef4ecf2a233da05981c892dd4..f80cc0f1977ea89e7da430f840a0bdcb09bce559 100644
--- a/bash-5.1/bashhist.c
+++ b/bash-5.1/bashhist.c
@@ -875,7 +875,7 @@ bash_add_history (line)
add_it = 1;
if (command_oriented_history && current_command_line_count > 1)
{
- is_comment = (parser_state & PST_HEREDOC) ? 0 : shell_comment (line);
+ is_comment = (parser_state & PST_HEREDOC) ? 0 : shell_comment (line); //开头是返回1,后面有返回2,没有返回0
/* The second and subsequent lines of a here document have the trailing
newline preserved. We don't want to add extra newlines here, but we
@@ -888,7 +888,7 @@ bash_add_history (line)
(current_command_line_count > 2)
don't add a newline here. This will also take care of the literal_history
case if the other conditions are met. */
- if ((parser_state & PST_HEREDOC) && current_command_line_count > 2 && line[strlen (line) - 1] == '\n')
+ if ((parser_state & PST_HEREDOC) && current_command_line_count > 2 && line[strlen (line) - 1] == '\n') //判断HEREDOC?
chars_to_add = "";
else if (current_command_line_count == current_command_line_comment+1)
chars_to_add = "\n";
@@ -930,7 +930,7 @@ bash_add_history (line)
+ strlen (chars_to_add));
sprintf (new_line, "%s%s%s", current->line, chars_to_add, line);
offset = where_history ();
- old = replace_history_entry (offset, new_line, current->data);
+ old = replace_history_entry (offset, new_line, current->data); //把history entry最后一项替换?
free (new_line);
if (old)
diff --git a/bash-5.1/builtins/Makefile b/bash-5.1/builtins/Makefile
deleted file mode 100644
index 0810901b0bd6b1d81a2c4fe9520ded47bcc73115..0000000000000000000000000000000000000000
--- a/bash-5.1/builtins/Makefile
+++ /dev/null
@@ -1,708 +0,0 @@
-# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
-#
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-PACKAGE = rash
-PACKAGE_BUGREPORT = bug-rash@gnu.org
-PACKAGE_NAME = rash
-PACKAGE_STRING = rash 0.1-release
-PACKAGE_VERSION = 0.1-release
-
-#
-SHELL = /bin/sh
-RANLIB = ranlib
-CC = gcc
-CC_FOR_BUILD = $(CC)
-AR = ar
-ARFLAGS = cr
-RM = rm -f
-CP = cp
-
-EXEEXT =
-
-prefix = /usr/local
-
-srcdir = .
-
-topdir = ..
-
-datarootdir = ${prefix}/share
-
-includedir = ${prefix}/include
-datadir = ${datarootdir}
-localedir = ${datarootdir}/locale
-
-loadablesdir = ${libdir}/bash
-
-# Support an alternate destination root directory for package building
-DESTDIR =
-
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-BUILD_DIR = /home/tong/src/bash/bash-5.1
-
-LIBBUILD = ${BUILD_DIR}/lib
-
-PROFILE_FLAGS =
-CFLAGS = -g -O2 -Wno-parentheses -Wno-format-security
-CFLAGS_FOR_BUILD = -g -O2 -Wno-parentheses -Wno-format-security
-CPPFLAGS =
-CPPFLAGS_FOR_BUILD =
-LOCAL_CFLAGS = ${DEBUG}
-DEFS = -DHAVE_CONFIG_H
-LOCAL_DEFS = -DSHELL
-
-LIBS = -ldl
-LDFLAGS = $(LOCAL_LDFLAGS) $(CFLAGS)
-LDFLAGS_FOR_BUILD = $(LDFLAGS) $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
-LOCAL_LDFLAGS = -rdynamic
-LIBS_FOR_BUILD = $(LIBS)
-#LIBS_FOR_BUILD = $(LIBS)
-
-BASHINCDIR = ${topdir}/include
-
-RL_INCLUDEDIR =
-
-INTL_LIBSRC = ${topdir}/lib/intl
-INTL_BUILDDIR = ${LIBBUILD}/intl
-INTL_LIBDIR = ${INTL_BUILDDIR}
-INTL_LIBRARY = ${INTL_BUILDDIR}/libintl.a
-INTL_INC =
-INTL_DEP =
-LIBINTL_H =
-
-HELPDIR =
-MKDIRS = ${topdir}/support/mkdirs
-
-HELPFILES_TARGET =
-
-INCLUDES = -I. -I.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC}
-
-BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
- ${INCLUDES} $(LOCAL_CFLAGS)
-
-CCFLAGS = ${ADDON_CFLAGS} $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
-
-CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
-
-GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
- -Wcast-align -Wstrict-prototypes -Wconversion \
- -Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic
-
-MKBUILTINS = mkbuiltins$(EXEEXT)
-DIRECTDEFINE = -D $(srcdir)
-HELPDIRDEFINE =
-HELPSTRINGS =
-
-# xxx this is bad style
-RL_LIBSRC = $(topdir)/lib/readline
-
-.SUFFIXES:
-.SUFFIXES: .def .c .o
-# How to make a .o file from a .def file.
-.def.o:
- $(RM) $@
- ./$(MKBUILTINS) $(DIRECTDEFINE) $<
- $(CC) -c $(CCFLAGS) $*.c || ( $(RM) $*.c ; exit 1 )
-
-# How to make a .c file from a .def file.
-.def.c:
- $(RM) $@
- ./$(MKBUILTINS) $(DIRECTDEFINE) $<
-
-# default rule for making a .o file from a .c file
-.c.o:
- $(RM) $@
- $(CC) -c $(CCFLAGS) $<
-
-DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \
- $(srcdir)/builtin.def $(srcdir)/caller.def \
- $(srcdir)/cd.def $(srcdir)/colon.def \
- $(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \
- $(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \
- $(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \
- $(srcdir)/fg_bg.def $(srcdir)/hash.def $(srcdir)/help.def \
- $(srcdir)/history.def $(srcdir)/jobs.def $(srcdir)/kill.def \
- $(srcdir)/let.def $(srcdir)/read.def $(srcdir)/return.def \
- $(srcdir)/set.def $(srcdir)/setattr.def $(srcdir)/shift.def \
- $(srcdir)/source.def $(srcdir)/suspend.def $(srcdir)/test.def \
- $(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \
- $(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \
- $(srcdir)/reserved.def $(srcdir)/pushd.def $(srcdir)/shopt.def \
- $(srcdir)/printf.def $(srcdir)/complete.def $(srcdir)/mapfile.def
-
-STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \
- getopt.h
-
-OFILES = builtins.o \
- alias.o bind.o break.o builtin.o caller.o cd.o colon.o command.o \
- common.o declare.o echo.o enable.o eval.o evalfile.o \
- evalstring.o exec.o exit.o fc.o fg_bg.o hash.o help.o history.o \
- jobs.o kill.o let.o mapfile.o \
- pushd.o read.o return.o set.o setattr.o shift.o source.o \
- suspend.o test.o times.o trap.o type.o ulimit.o umask.o \
- wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o
-
-CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h tmpbuiltins.c \
- tmpbuiltins.h
-CREATED_OBJECTS = tmpbuiltins.o gen-helpfiles.o mkbuiltins.o
-
-all: $(MKBUILTINS) libbuiltins.a $(HELPFILES_TARGET)
-targets: libbuiltins.a $(HELPFILES_TARGET)
-
-libbuiltins.a: $(MKBUILTINS) $(OFILES) builtins.o
- $(RM) $@
- $(AR) $(ARFLAGS) $@ $(OFILES)
- -$(RANLIB) $@
-
-tmpbuiltins.c: $(MKBUILTINS) $(DEFSRC)
- ./$(MKBUILTINS) -externfile tmpbuiltins.h -structfile $@ \
- -noproduction -nofunctions \
- $(DIRECTDEFINE) $(HELPSTRINGS) $(DEFSRC)
-
-tmpbuiltins.h: tmpbuiltins.c
-
-gen-helpfiles.o: ../config.h
-gen-helpfiles.o: gen-helpfiles.c
- $(RM) $@
- $(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
-
-gen-helpfiles: tmpbuiltins.o gen-helpfiles.o
- $(CC_FOR_BUILD) ${CCFLAGS_FOR_BUILD} $(LDFLAGS_FOR_BUILD) -o $@ gen-helpfiles.o tmpbuiltins.o $(LIBS_FOR_BUILD)
-
-builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC)
- @-if test -f builtins.c; then mv -f builtins.c old-builtins.c; fi
- @-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi
- ./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \
- -noproduction $(DIRECTDEFINE) $(HELPDIRDEFINE) $(HELPSTRINGS) $(DEFSRC)
- @-if cmp -s old-builtext.h builtext.h 2>/dev/null; then \
- mv old-builtext.h builtext.h; \
- else \
- $(RM) old-builtext.h; \
- fi
- @-if cmp -s old-builtins.c builtins.c 2>/dev/null; then \
- mv old-builtins.c builtins.c; \
- else \
- $(RM) old-builtins.c; \
- fi
-
-helpdoc: gen-helpfiles
- ./gen-helpfiles ${HELPDIRDEFINE}
-
-install-help:
- @-if test -n "${HELPDIR}" && test -d helpfiles ; then \
- test -d $(DESTDIR)${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\
- ( for f in helpfiles/*; do \
- echo installing $$f; \
- ${INSTALL_DATA} $$f $(DESTDIR)$(HELPDIR); \
- done; ) ; \
- fi
-
-install:
-
-mkbuiltins.o: ../config.h
-mkbuiltins.o: mkbuiltins.c
- $(RM) $@
- $(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $<
-
-mkbuiltins$(EXEEXT): mkbuiltins.o
- $(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $(MKBUILTINS) mkbuiltins.o $(LIBS_FOR_BUILD)
-
-# rules for deficient makes, like SunOS
-mkbuiltins.o: mkbuiltins.c
-builtins.o: builtins.c
-common.o: common.c
-bashgetopt.o: bashgetopt.c
-getopt.o: getopt.c
-evalstring.o: evalstring.c
-evalfile.o: evalfile.c
-
-tmpbuiltins.o: tmpbuiltins.c
-gen-helpfiles.o: gen-helpfiles.c
-
-ulimit.o: pipesize.h
-
-pipesize.h: psize.aux
- $(SHELL) $(srcdir)/psize.sh > $@
-
-# Technically this is wrong; the pipe size should be for the target system,
-# not the build host.
-psize.aux: psize.c
- $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(srcdir)/psize.c
-
-documentation: builtins.texi
-
-builtins.texi: $(MKBUILTINS)
- ./$(MKBUILTINS) -documentonly $(DEFSRC)
-
-clean:
- $(RM) $(OFILES) $(CREATED_FILES) libbuiltins.a
- $(RM) $(MKBUILTINS) gen-helpfiles $(CREATED_OBJECTS)
- -test -d helpfiles && $(RM) -r helpfiles
-
-mostlyclean:
- $(RM) $(OFILES) libbuiltins.a
-
-distclean maintainer-clean: clean
- $(RM) Makefile
-
-$(OFILES): $(MKBUILTINS) ../config.h
-
-../version.h: ../config.h ../Makefile Makefile
- -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h )
-
-# maintainer special - for now
-po: builtins.c
- xgettext -L C -o $(topdir)/po/builtins.pot --keyword='N_' builtins.c 2>/dev/null
-
-${LIBINTL_H}:
- @echo making $@ in ${INTL_BUILDDIR}
- @(cd ${INTL_BUILDDIR} && \
- $(MAKE) $(MFLAGS) libintl.h) || exit 1
-
-# dependencies
-
-alias.o: alias.def
-bind.o: bind.def
-break.o: break.def
-builtin.o: builtin.def
-caller.o: caller.def
-cd.o: cd.def
-colon.o: colon.def
-command.o: command.def
-declare.o: declare.def
-echo.o: echo.def
-enable.o: enable.def
-eval.o: eval.def
-exec.o: exec.def
-exit.o: exit.def
-fc.o: fc.def
-fg_bg.o: fg_bg.def
-hash.o: hash.def
-help.o: help.def
-history.o: history.def
-jobs.o: jobs.def
-kill.o: kill.def
-let.o: let.def
-mapfile.o: mapfile.def
-printf.o: printf.def
-pushd.o: pushd.def
-read.o: read.def
-return.o: return.def
-set.o: set.def
-setattr.o: setattr.def
-shift.o: shift.def
-shopt.o: shopt.def
-source.o: source.def
-suspend.o: suspend.def
-test.o: test.def
-times.o: times.def
-trap.o: trap.def
-type.o: type.def
-ulimit.o: ulimit.def
-umask.o: umask.def
-wait.o: wait.def
-getopts.o: getopts.def
-reserved.o: reserved.def
-complete.o: complete.def
-
-# C files
-bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-bashgetopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h
-bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h
-bashgetopt.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
-bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
-bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
-bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h
-bashgetopt.o: $(BASHINCDIR)/chartypes.h
-common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
-common.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/parser.h
-common.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
-common.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h
-common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
-common.o: $(topdir)/unwind_prot.h $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h
-common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h
-common.o: $(topdir)/externs.h ../pathnames.h ./builtext.h
-common.o: $(BASHINCDIR)/chartypes.h
-evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
-evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-evalfile.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h
-evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h
-evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
-evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
-evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
-evalfile.o: ../pathnames.h $(topdir)/externs.h $(topdir)/parser.h
-evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
-evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
-evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
-evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-evalstring.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
-evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
-evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h
-evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
-evalstring.o: $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
-evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h
-evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h
-evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h
-evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h ./builtext.h
-#evalstring.o: $(topdir)/y.tab.h
-getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
-getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h
-getopt.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h $(topdir)/variables.h $(topdir)/conftypes.h
-getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h
-getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-getopt.o: $(topdir)/sig.h ../pathnames.h $(topdir)/externs.h
-getopt.o: $(srcdir)/getopt.h
-mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
-mkbuiltins.o: ${BASHINCDIR}/filecntl.h
-mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
-
-# def files
-alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
-alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h
-alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-alias.o: ../pathnames.h
-bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
-bind.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
-bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-break.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-break.o: ../pathnames.h $(topdir)/execute_cmd.h
-builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
-builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
-builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h $(topdir)/execute_cmd.h
-caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
-caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h
-caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h ../pathnames.h
-cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
-cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
-cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h
-cd.o: $(topdir)/sig.h
-colon.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-colon.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
-colon.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-colon.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-colon.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
-colon.o: $(srcdir)/common.h
-command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
-command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
-command.o: $(topdir)/sig.h
-command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-command.o: ../pathnames.h
-declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-declare.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h $(topdir)/flags.h
-declare.o: ./builtext.h ../pathnames.h
-echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
-echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
-echo.o: $(srcdir)/common.h
-enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-enable.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-enable.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
-enable.o: $(topdir)/pcomplete.h
-eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-eval.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-eval.o: $(BASHINCDIR)/maxpath.h ../pathnames.h
-exec.o: $(topdir)/bashtypes.h
-exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-exec.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
-exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
-exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h ../pathnames.h
-exit.o: $(topdir)/bashtypes.h
-exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h
-exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-exit.o: $(topdir)/execute_cmd.h
-exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h
-fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
-fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
-fc.o: $(topdir)/bashhist.h $(topdir)/parser.h
-fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
-fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h
-fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h
-fc.o: ../pathnames.h
-fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h
-fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-fg_bg.o: $(topdir)/execute_cmd.h
-fg_bg.o: $(topdir)/jobs.h ../pathnames.h
-getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-getopts.o: $(topdir)/execute_cmd.h
-getopts.o: ../pathnames.h
-hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
-hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h
-hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-hash.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
-hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h
-help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-help.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
-help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h
-history.o: $(topdir)/bashtypes.h
-history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h $(topdir)/parser.h
-history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
-history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
-history.o: ../pathnames.h
-inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-inlib.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
-inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h ../pathnames.h
-jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
-jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h $(topdir)/jobs.h
-jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-jobs.o: $(topdir)/sig.h ../pathnames.h
-kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
-kill.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
-kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h
-kill.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/maxpath.h
-kill.o: $(topdir)/jobs.h ../pathnames.h
-let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-let.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-let.o: ../pathnames.h
-printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
-printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
-printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
-printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h
-printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-printf.o: ../pathnames.h
-pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-pushd.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
-pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
-pushd.o: ../pathnames.h
-read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-read.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-read.o: $(BASHINCDIR)/shtty.h $(topdir)/sig.h
-read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
-read.o: $(topdir)/arrayfunc.h ../pathnames.h
-return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-return.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
-return.o: ../pathnames.h
-set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-set.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
-set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.h
-set.o: $(topdir)/arrayfunc.h ../pathnames.h $(topdir)/parser.h
-setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
-setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
-setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-setattr.o: $(topdir)/externs.h $(topdir)/flags.h $(topdir)/sig.h
-setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-setattr.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
-setattr.o: $(topdir)/arrayfunc.h ../pathnames.h
-shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-shift.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-shift.o: ../pathnames.h
-shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-shopt.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h ../pathnames.h
-shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h $(topdir)/sig.h
-source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/findcmd.h
-source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h
-source.o: $(topdir)/execute_cmd.h
-source.o: ../pathnames.h
-suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-suspend.o: $(topdir)/jobs.h ../pathnames.h
-test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-test.o: $(topdir)/execute_cmd.h $(topdir)/test.h ../pathnames.h
-times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-times.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-times.o: $(BASHINCDIR)/posixtime.h ../pathnames.h
-trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
-trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
-trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-trap.o: $(topdir)/findcmd.h ../pathnames.h
-type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-type.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
-type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
-type.o: $(topdir)/execute_cmd.h $(topdir)/parser.h
-type.o: $(topdir)/externs.h $(topdir)/hashcmd.h ../pathnames.h
-type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-ulimit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-ulimit.o: ../pathnames.h
-umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-umask.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-umask.o: $(BASHINCDIR)/chartypes.h ../pathnames.h
-wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
-wait.o: $(topdir)/jobs.h $(topdir)/sig.h $(topdir)/execute_cmd.h
-wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h
-
-complete.o: ../config.h ../pathnames.h
-complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
-complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
-complete.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
-complete.o: ${topdir}/builtins.h ${topdir}/general.h
-complete.o: ${topdir}/bashtypes.h ${BASHINCDIR}/chartypes.h ${topdir}/xmalloc.h
-complete.o: ${topdir}/pcomplete.h
-complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
-mapfile.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
-mapfile.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
-mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
-mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
-mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h
-mapfile.o: $(topdir)/arrayfunc.h ../pathnames.h
-
-#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h
-
-# libintl dependencies
-bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
-umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
diff --git a/bash-5.1/builtins/common.c b/bash-5.1/builtins/common.c
index 3c9ac49de174891d6e79b68e04077ec134ee5b64..f4a823cac437d27a8e55a5e971ac1722484d1a22 100644
--- a/bash-5.1/builtins/common.c
+++ b/bash-5.1/builtins/common.c
@@ -613,6 +613,7 @@ read_octal (string)
FOR_WHOM is the name of the caller for error printing. */
char *the_current_working_directory = (char *)NULL;
+// job.c : dir = get_working_directory ("job-working-directory");
char *
get_working_directory (for_whom)
char *for_whom;
diff --git a/bash-5.1/builtins/read.def b/bash-5.1/builtins/read.def
index b28ed06f60a416864445ca94643617a18b9cce69..6279564cd1b974d9ed3f2f559f8381c4c03f225e 100644
--- a/bash-5.1/builtins/read.def
+++ b/bash-5.1/builtins/read.def
@@ -135,7 +135,7 @@ static sighandler sigalrm PARAMS((int));
static void reset_alarm PARAMS((void));
/* Try this to see what the rest of the shell can do with the information. */
-procenv_t alrmbuf;
+extern procenv_t alrmbuf;
int sigalrm_seen;
static int reading, tty_modified;
diff --git a/bash-5.1/builtins/wait.def b/bash-5.1/builtins/wait.def
index c55204ef08b7a2f24b54d4bd19b9e9195a604912..7c843e20bdf6d88fe85327c9f8ad995ac1ed005f 100644
--- a/bash-5.1/builtins/wait.def
+++ b/bash-5.1/builtins/wait.def
@@ -88,7 +88,7 @@ $END
extern int wait_signal_received;
extern procenv_t wait_intr_buf;
-int wait_intr_flag;
+extern int wait_intr_flag;
static int set_waitlist PARAMS((WORD_LIST *));
static void unset_waitlist PARAMS((void));
diff --git a/bash-5.1/builtins_rust/alias/src/lib.rs b/bash-5.1/builtins_rust/alias/src/lib.rs
index ed6eea91d8d859eb777dccc6045fbe5268e6768f..4f45bf50aa58a17926153b4f22990fdfe5c3ac70 100644
--- a/bash-5.1/builtins_rust/alias/src/lib.rs
+++ b/bash-5.1/builtins_rust/alias/src/lib.rs
@@ -1,11 +1,13 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
use std::ffi::CStr;
//extern crate rcommon;
-use rcommon::r_sh_notfound;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,r_builtin_usage,SHELL_VAR};
+
+use rcommon::{
+ r_builtin_usage, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE, SHELL_VAR,
+};
use rhelp::r_builtin_help;
use std::ffi::CString;
extern "C" {
@@ -31,9 +33,9 @@ extern "C" {
fn sh_chkwrite(_: libc::c_int) -> libc::c_int;
static mut loptend: *mut WordList;
fn internal_getopt(_: *mut WordList, _: *mut libc::c_char) -> libc::c_int;
- fn find_user_command(name:*const libc::c_char)->*mut libc::c_char;
+ fn find_user_command(name: *const libc::c_char) -> *mut libc::c_char;
fn find_shell_builtin(builtin: *mut libc::c_char) -> *mut libc::c_char;
- fn find_function (name:* const libc::c_char)-> *mut SHELL_VAR;
+ fn find_function(name: *const libc::c_char) -> *mut SHELL_VAR;
fn reset_internal_getopt();
}
pub type SizeT = libc::c_ulong;
@@ -63,18 +65,22 @@ pub struct alias {
pub flags: libc::c_char,
}
pub type AliasT = alias;
-pub static AL_REUSABLE:i32 = 0x01;
+pub static AL_REUSABLE: i32 = 0x01;
#[no_mangle]
pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int {
let mut any_failed;
let mut offset;
- let mut pflag ;
- let mut dflags ;
- let alias_list: *mut *mut AliasT;
+ let mut pflag;
+ let mut dflags;
+ let alias_list: *mut *mut AliasT;
let mut t: *mut AliasT;
let mut name: *mut libc::c_char;
let mut value: *mut libc::c_char;
- dflags = if posixly_correct != 0 { 0 as libc::c_int } else { 0x1 as libc::c_int };
+ dflags = if posixly_correct != 0 {
+ 0 as libc::c_int
+ } else {
+ 0x1 as libc::c_int
+ };
pflag = 0 as libc::c_int;
reset_internal_getopt();
loop {
@@ -87,7 +93,7 @@ pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int
}
match offset as u8 {
b'p' => {
- pflag = 1 ;
+ pflag = 1;
dflags |= AL_REUSABLE;
}
_ => {
@@ -130,23 +136,24 @@ pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int
}
if offset != 0 && *name.offset(offset as isize) as libc::c_int == '=' as i32 {
*name.offset(offset as isize) = '\u{0}' as i32 as libc::c_char;
- value = name.offset(offset as isize).offset(1 as libc::c_int as isize);
+ value = name
+ .offset(offset as isize)
+ .offset(1 as libc::c_int as isize);
if legal_alias_name(name, 0) == 0 {
builtin_error(
dcgettext(
0 as *const libc::c_char,
- b"`%s': invalid alias name\0" as *const u8
- as *const libc::c_char,
+ b"`%s': invalid alias name\0" as *const u8 as *const libc::c_char,
5 as libc::c_int,
),
name,
);
any_failed += 1;
} else {
- let slice= CStr::from_ptr(value);
- let mut r_str=slice.to_str().unwrap().to_owned();
- let new_str = CString::new(r_str).unwrap();
- if legal_alias_rust(name,new_str.as_ptr() as *mut libc::c_char) == 0 {
+ let slice = CStr::from_ptr(value);
+ let r_str = slice.to_str().unwrap().to_owned();
+ let new_str = CString::new(r_str).unwrap();
+ if legal_alias_rust(name, new_str.as_ptr() as *mut libc::c_char) == 0 {
add_alias(name, value);
}
}
@@ -161,7 +168,11 @@ pub unsafe extern "C" fn r_alias_builtin(mut list: *mut WordList) -> libc::c_int
}
list = (*list).next;
}
- return if any_failed != 0 {EXECUTION_FAILURE!()} else { EXECUTION_SUCCESS!()};
+ return if any_failed != 0 {
+ EXECUTION_FAILURE!()
+ } else {
+ EXECUTION_SUCCESS!()
+ };
}
#[no_mangle]
pub unsafe extern "C" fn r_unalias_builtin(mut list: *mut WordList) -> libc::c_int {
@@ -212,94 +223,125 @@ pub unsafe extern "C" fn r_unalias_builtin(mut list: *mut WordList) -> libc::c_i
}
list = (*list).next;
}
- return if aflag != 0 { 1 as libc::c_int } else { 0 as libc::c_int };
+ return if aflag != 0 {
+ 1 as libc::c_int
+ } else {
+ 0 as libc::c_int
+ };
}
-unsafe extern "C" fn print_alias( alias: *mut AliasT, flags: libc::c_int) {
+unsafe extern "C" fn print_alias(alias: *mut AliasT, flags: libc::c_int) {
let value: *mut libc::c_char;
value = sh_single_quote((*alias).value);
if flags & 0x1 as libc::c_int != 0 {
print!("alias ");
//printf(
// b"alias %s\0" as *const u8 as *const libc::c_char,
- if !((*alias).name).is_null()
- && *((*alias).name).offset(0 as libc::c_int as isize) as libc::c_int
- == '-' as i32
- {
- // b"-- \0" as *const u8 as *const libc::c_char
- print!("-- ");
- } else {
- // b"\0" as *const u8 as *const libc::c_char
- print!(" ");
- }
+ if !((*alias).name).is_null()
+ && *((*alias).name).offset(0 as libc::c_int as isize) as libc::c_int == '-' as i32
+ {
+ // b"-- \0" as *const u8 as *const libc::c_char
+ print!("-- ");
+ } else {
+ // b"\0" as *const u8 as *const libc::c_char
+ print!(" ");
+ }
//);
}
- println!("{}={}", CStr::from_ptr((*alias).name).to_string_lossy().into_owned(), CStr::from_ptr(value).to_string_lossy().into_owned());
+ println!(
+ "{}={}",
+ CStr::from_ptr((*alias).name).to_string_lossy().into_owned(),
+ CStr::from_ptr(value).to_string_lossy().into_owned()
+ );
free(value as *mut libc::c_void);
}
-unsafe fn legal_alias_rust(name :*mut libc::c_char,value :*mut libc::c_char ) -> libc::c_int {
-
- let mut name_w:*mut libc::c_char;
- let mut value_w:*mut libc::c_char;
- let mut new_value:*mut libc::c_char;
- let mut new_value_2:*mut libc::c_char;
- let mut shell_bui : *mut libc::c_char;
+unsafe fn legal_alias_rust(name: *mut libc::c_char, value: *mut libc::c_char) -> libc::c_int {
+ let name_w: *mut libc::c_char;
+ let value_w: *mut libc::c_char;
+ let new_value: *mut libc::c_char;
+ let mut new_value_2: *mut libc::c_char;
+ let mut _shell_bui: *mut libc::c_char;
let mut t: *mut AliasT;
- let mut dflags ;
- dflags = if posixly_correct != 0 { 0 as libc::c_int } else { 0x1 as libc::c_int };
-
- if libc::strstr(value,CString::new(";").unwrap().as_ptr() as *mut libc::c_char) != std::ptr::null_mut() {
+ let dflags;
+ dflags = if posixly_correct != 0 {
+ 0 as libc::c_int
+ } else {
+ 0x1 as libc::c_int
+ };
+
+ if libc::strstr(
+ value,
+ CString::new(";").unwrap().as_ptr() as *mut libc::c_char,
+ ) != std::ptr::null_mut()
+ {
println!("; is not allow in alias");
- return 1;
+ return 1;
}
t = find_alias(name);
if !t.is_null() {
- println!("{} is already in alias", CStr::from_ptr(name).to_string_lossy().into_owned());
+ println!(
+ "{} is already in alias",
+ CStr::from_ptr(name).to_string_lossy().into_owned()
+ );
print_alias(t, dflags);
- return 1;
+ return 1;
}
name_w = find_user_command(name);
new_value = sh_single_quote(value);
// 按照空格区分
- new_value_2 = libc::strtok(value, CString::new(" ").unwrap().as_ptr() as *mut libc::c_char) ;
+ new_value_2 = libc::strtok(
+ value,
+ CString::new(" ").unwrap().as_ptr() as *mut libc::c_char,
+ );
t = find_alias(new_value_2);
while t != std::ptr::null_mut() {
- new_value_2 = libc::strtok((*t).value, CString::new(" ").unwrap().as_ptr() as *mut libc::c_char) ;
- if libc::strcmp((*t).name,new_value_2) == 0 {
+ new_value_2 = libc::strtok(
+ (*t).value,
+ CString::new(" ").unwrap().as_ptr() as *mut libc::c_char,
+ );
+ if libc::strcmp((*t).name, new_value_2) == 0 {
break;
}
t = find_alias(new_value_2);
}
- let arr:[ *mut libc::c_char;7] = [CString::new("exec").unwrap().into_raw() as *mut libc::c_char,
- CString::new("eval").unwrap().into_raw() as *mut libc::c_char,
- CString::new("builtin").unwrap().into_raw() as *mut libc::c_char,
- CString::new("command").unwrap().into_raw() as *mut libc::c_char,
- CString::new("function").unwrap().into_raw() as *mut libc::c_char,
- CString::new("source").unwrap().into_raw() as *mut libc::c_char,
- CString::new(".").unwrap().into_raw() as *mut libc::c_char ];
-
+ let arr: [*mut libc::c_char; 7] = [
+ CString::new("exec").unwrap().into_raw() as *mut libc::c_char,
+ CString::new("eval").unwrap().into_raw() as *mut libc::c_char,
+ CString::new("builtin").unwrap().into_raw() as *mut libc::c_char,
+ CString::new("command").unwrap().into_raw() as *mut libc::c_char,
+ CString::new("function").unwrap().into_raw() as *mut libc::c_char,
+ CString::new("source").unwrap().into_raw() as *mut libc::c_char,
+ CString::new(".").unwrap().into_raw() as *mut libc::c_char,
+ ];
+
for index in 0..7 {
if libc::strcmp(new_value_2, arr[index]) == 0 {
- println!("command {} will raise an unsafe operation",CStr::from_ptr(arr[index]).to_string_lossy().into_owned());
- return 1;
+ println!(
+ "command {} will raise an unsafe operation",
+ CStr::from_ptr(arr[index]).to_string_lossy().into_owned()
+ );
+ return 1;
}
}
value_w = find_user_command(new_value_2);
- if name_w != std::ptr::null_mut(){
- if value_w != std::ptr::null_mut() && libc::strcmp(name_w, value_w) == 0 {
+ if name_w != std::ptr::null_mut() {
+ if value_w != std::ptr::null_mut() && libc::strcmp(name_w, value_w) == 0 {
return 0;
- }
- else {
+ } else {
println!("The name and value point to different executable files");
- return 1 ;
- }
- }
- else {
- if find_shell_builtin(name) != std::ptr::null_mut() {
- println!("name {} is shell builtin",CStr::from_ptr(name).to_string_lossy().into_owned());
return 1;
}
- else if find_function(name) != std::ptr::null_mut() {
- println!("name {} is function",CStr::from_ptr(name).to_string_lossy().into_owned());
+ } else {
+ if find_shell_builtin(name) != std::ptr::null_mut() {
+ println!(
+ "name {} is shell builtin",
+ CStr::from_ptr(name).to_string_lossy().into_owned()
+ );
+ return 1;
+ } else if find_function(name) != std::ptr::null_mut() {
+ println!(
+ "name {} is function",
+ CStr::from_ptr(name).to_string_lossy().into_owned()
+ );
return 1;
}
}
diff --git a/bash-5.1/builtins_rust/bind/src/lib.rs b/bash-5.1/builtins_rust/bind/src/lib.rs
index 45246a3e4de25f426c884bb403e9f994ab6052ce..d1fd07a273826614722607b43cd0573b6b0530a9 100644
--- a/bash-5.1/builtins_rust/bind/src/lib.rs
+++ b/bash-5.1/builtins_rust/bind/src/lib.rs
@@ -1,179 +1,213 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate nix;
extern crate rcommon;
-use libc::{c_char,c_int,strerror,free, c_void, strlen, size_t,};
-use std::{ffi::{CString,CStr}};
-use std::fs::File;
+use libc::{c_char, c_int, c_void, free, size_t, strerror, strlen};
use nix::errno::errno;
-use rcommon::{r_builtin_usage,r_sh_chkwrite,err_translate_fn,translate_fn};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{err_translate_fn, r_builtin_usage, r_sh_chkwrite, translate_fn};
+use rcommon::{WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
+use std::ffi::{CStr, CString};
+use std::fs::File;
-#[repr (C)]
-pub struct _keymap_entry{
- pub Type:c_char,
- pub function:rl_command_func_t,
+#[repr(C)]
+pub struct _keymap_entry {
+ pub Type: c_char,
+ pub function: rl_command_func_t,
}
type KEYMAP_ENTRY = _keymap_entry;
type Keymap = *mut KEYMAP_ENTRY;
-type rl_command_func_t = extern fn(c_int,c_int)->c_int;
+type rl_command_func_t = extern "C" fn(c_int, c_int) -> c_int;
//emun
#[macro_export]
macro_rules! LFLAG {
- () => { 0x0001 }
+ () => {
+ 0x0001
+ };
}
#[macro_export]
macro_rules! PFLAG {
- () => { 0x0002 }
+ () => {
+ 0x0002
+ };
}
#[macro_export]
macro_rules! FFLAG {
- () => { 0x0004 }
+ () => {
+ 0x0004
+ };
}
#[macro_export]
macro_rules! VFLAG {
- () => { 0x0008 }
+ () => {
+ 0x0008
+ };
}
#[macro_export]
macro_rules! QFLAG {
- () => { 0x0010 }
+ () => {
+ 0x0010
+ };
}
#[macro_export]
macro_rules! MFLAG {
- () => { 0x0020 }
+ () => {
+ 0x0020
+ };
}
#[macro_export]
macro_rules! RFLAG {
- () => { 0x0040 }
+ () => {
+ 0x0040
+ };
}
#[macro_export]
macro_rules! PPFLAG {
- () => { 0x0080 }
+ () => {
+ 0x0080
+ };
}
#[macro_export]
macro_rules! VVFLAG {
- () => { 0x0100 }
+ () => {
+ 0x0100
+ };
}
#[macro_export]
macro_rules! SFLAG {
- () => { 0x0200 }
+ () => {
+ 0x0200
+ };
}
#[macro_export]
macro_rules! SSFLAG {
- () => { 0x0400 }
+ () => {
+ 0x0400
+ };
}
#[macro_export]
macro_rules! UFLAG {
- () => { 0x0800 }
+ () => {
+ 0x0800
+ };
}
#[macro_export]
macro_rules! XFLAG {
- () => { 0x1000 }
+ () => {
+ 0x1000
+ };
}
#[macro_export]
macro_rules! XXFLAG {
- () => { 0x2000 }
+ () => {
+ 0x2000
+ };
}
#[macro_export]
macro_rules! ISKMAP {
- () => { 1 }
+ () => {
+ 1
+ };
}
#[macro_export]
-macro_rules! KEYMAP_SIZE{
- () => { 257 }
+macro_rules! KEYMAP_SIZE {
+ () => {
+ 257
+ };
}
#[macro_export]
-macro_rules! ANYOTHERKEY{
- () => { KEYMAP_SIZE!() - 1}
+macro_rules! ANYOTHERKEY {
+ () => {
+ KEYMAP_SIZE!() - 1
+ };
}
-
-extern "C"{
+extern "C" {
fn dcgettext(
__domainname: *const libc::c_char,
__msgid: *const libc::c_char,
__category: libc::c_int,
) -> *mut libc::c_char;
- static no_line_editing:i32;
- static bash_readline_initialized:i32;
- static mut rl_outstream:*mut File;
- static stdout:*mut File;
- static list_optarg:*mut c_char;
- static loptend:*mut WordList;
-
- fn builtin_warning(format:*const c_char,...);
+ static no_line_editing: i32;
+ static bash_readline_initialized: i32;
+ static mut rl_outstream: *mut File;
+ static stdout: *mut File;
+ static list_optarg: *mut c_char;
+ static loptend: *mut WordList;
+
+ fn builtin_warning(format: *const c_char, ...);
fn initialize_readline();
- fn begin_unwind_frame(tar:*mut c_char);
- fn run_unwind_frame(tag:*mut c_char);
- fn unwind_protect_mem(var:*mut c_char,size:i32);
+ fn begin_unwind_frame(tar: *mut c_char);
+ fn run_unwind_frame(tag: *mut c_char);
+ fn unwind_protect_mem(var: *mut c_char, size: i32);
fn reset_internal_getopt();
- fn internal_getopt(list:*mut WordList,opts:*mut c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
// fn builtin_usage();
- fn rl_set_keymap(map:Keymap);
+ fn rl_set_keymap(map: Keymap);
// fn sh_chkwrite(s:i32)->i32;
- fn builtin_error(format:*const c_char,...);
- fn rl_named_function(string:*const c_char)->*mut rl_command_func_t;
- fn rl_invoking_keyseqs(function:*mut rl_command_func_t)->*mut *mut c_char;
- fn strvec_dispose(array:*mut *mut c_char);
- fn rl_unbind_function_in_map(func:*mut rl_command_func_t,map:Keymap)->i32;
- fn rl_get_keymap()->Keymap;
- fn unbind_unix_command(kseq:*mut c_char)->i32;
- fn bash_execute_unix_command(count:i32,key:i32)->i32;
- fn rl_bind_keyseq(keyseq:*const c_char,function:*mut rl_command_func_t)->i32;
- fn rl_function_of_keyseq_len(keyseq:*const c_char,len:size_t,map:Keymap,Type:*mut i32)->*mut rl_command_func_t;
- fn rl_translate_keyseq(seq:*const c_char,array:*mut c_char,len:*mut i32)->i32;
- fn xmalloc(n:size_t)->*mut c_void;
- fn rl_get_keymap_by_name(name:*const c_char)->Keymap;
+ fn builtin_error(format: *const c_char, ...);
+ fn rl_named_function(string: *const c_char) -> *mut rl_command_func_t;
+ fn rl_invoking_keyseqs(function: *mut rl_command_func_t) -> *mut *mut c_char;
+ fn strvec_dispose(array: *mut *mut c_char);
+ fn rl_unbind_function_in_map(func: *mut rl_command_func_t, map: Keymap) -> i32;
+ fn rl_get_keymap() -> Keymap;
+ fn unbind_unix_command(kseq: *mut c_char) -> i32;
+ fn bash_execute_unix_command(count: i32, key: i32) -> i32;
+ fn rl_bind_keyseq(keyseq: *const c_char, function: *mut rl_command_func_t) -> i32;
+ fn rl_function_of_keyseq_len(
+ keyseq: *const c_char,
+ len: size_t,
+ map: Keymap,
+ Type: *mut i32,
+ ) -> *mut rl_command_func_t;
+ fn rl_translate_keyseq(seq: *const c_char, array: *mut c_char, len: *mut i32) -> i32;
+ fn xmalloc(n: size_t) -> *mut c_void;
+ fn rl_get_keymap_by_name(name: *const c_char) -> Keymap;
fn rl_list_funmap_names();
- fn rl_function_dumper(print_readably:i32);
- fn rl_macro_dumper(print_readably:i32);
- fn rl_variable_dumper(print_readably:i32);
- fn rl_read_init_file(filename:*const c_char)->i32;
- fn printable_filename(Fn:*mut c_char,flags:i32)->*mut c_char;
+ fn rl_function_dumper(print_readably: i32);
+ fn rl_macro_dumper(print_readably: i32);
+ fn rl_variable_dumper(print_readably: i32);
+ fn rl_read_init_file(filename: *const c_char) -> i32;
+ fn printable_filename(Fn: *mut c_char, flags: i32) -> *mut c_char;
// fn query_bindings(name:*mut c_char)->i32;
// fn unbind_command(name:*mut c_char)->i32;
// fn unbind_keyseq(seq:*mut c_char)->i32;
- fn bind_keyseq_to_unix_command(line:*mut c_char)->i32;
- fn print_unix_command_map()->i32;
- fn strvec_len(array:*mut *mut c_char)->i32;
- fn rl_parse_and_bind(string:*mut c_char)->i32;
- fn strvec_search(array:*mut *mut c_char,name:*mut c_char)->i32;
+ fn bind_keyseq_to_unix_command(line: *mut c_char) -> i32;
+ fn print_unix_command_map() -> i32;
+ fn strvec_len(array: *mut *mut c_char) -> i32;
+ fn rl_parse_and_bind(string: *mut c_char) -> i32;
+ fn strvec_search(array: *mut *mut c_char, name: *mut c_char) -> i32;
}
-
#[no_mangle]
-pub extern "C" fn r_bind_builtin(mut list:*mut WordList)->i32{
- let mut return_code:i32;
- let mut kmap:Keymap;
- let mut saved_keymap:Keymap;
- let mut flags:i32;
- let mut opt:i32;
- let mut initfile:*mut c_char;
- let mut map_name:*mut c_char;
- let mut fun_name:*mut c_char;
- let mut unbind_name:*mut c_char;
- let mut remove_seq:*mut c_char;
- let mut cmd_seq:*mut c_char;
- let t:*mut c_char;
-
- unsafe{
- if no_line_editing != 0{
- builtin_warning(
- dcgettext(
+pub extern "C" fn r_bind_builtin(mut list: *mut WordList) -> i32 {
+ let mut return_code: i32;
+ let mut kmap: Keymap;
+ let mut saved_keymap: Keymap;
+ let mut flags: i32;
+ let mut opt: i32;
+ let mut initfile: *mut c_char;
+ let mut map_name: *mut c_char;
+ let mut fun_name: *mut c_char;
+ let mut unbind_name: *mut c_char;
+ let mut remove_seq: *mut c_char;
+ let mut cmd_seq: *mut c_char;
+ let t: *mut c_char;
+
+ unsafe {
+ if no_line_editing != 0 {
+ builtin_warning(dcgettext(
0 as *const libc::c_char,
CString::new("line editing not enabled").unwrap().as_ptr() as *const libc::c_char,
5 as libc::c_int,
- ),
- );
-
+ ));
}
kmap = std::ptr::null_mut();
diff --git a/bash-5.1/builtins_rust/break_1/src/lib.rs b/bash-5.1/builtins_rust/break_1/src/lib.rs
index 1b81ba00acb29994253a36efaf8bd539ea74eeb8..9da3f71b7731e0049b5b0ca84d80c51945cc1a23 100644
--- a/bash-5.1/builtins_rust/break_1/src/lib.rs
+++ b/bash-5.1/builtins_rust/break_1/src/lib.rs
@@ -1,18 +1,17 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
#[macro_use]
#[warn(temporary_cstring_as_ptr)]
-extern crate libc;
+extern crate libc;
extern crate nix;
-use std::ffi::CString;
use libc::c_long;
+use std::ffi::CString;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
-
type intmax_t = c_long;
/*
#[macro_export]
@@ -32,100 +31,103 @@ macro_rules! CHECK_HELPOPT {
}
}
*/
-fn checkhelp(l: *mut WordList) -> i32{
+fn checkhelp(l: *mut WordList) -> i32 {
unsafe {
- let tmp=CString::new("--help").unwrap();
- if l!=std::ptr::null_mut() && (*l).word !=std::ptr::null_mut() &&
- libc::strcmp((*((*l).word)).word, tmp.as_ptr()) == 0 {
+ let tmp = CString::new("--help").unwrap();
+ if l != std::ptr::null_mut()
+ && (*l).word != std::ptr::null_mut()
+ && libc::strcmp((*((*l).word)).word, tmp.as_ptr()) == 0
+ {
r_builtin_help();
}
- return EX_USAGE;
+ return EX_USAGE;
}
}
extern "C" {
- fn get_numeric_arg(list :*mut WordList, i: i32 , intmax :*mut intmax_t) -> i32;
- // fn get_loop_level() -> i32;
+ fn get_numeric_arg(list: *mut WordList, i: i32, intmax: *mut intmax_t) -> i32;
+ // fn get_loop_level() -> i32;
//fn set_continuing(cont : i32);
//fn set_breaking(breaking : i32);
- fn sh_erange (s:* mut libc::c_char, desc:* mut libc::c_char);
+ fn sh_erange(s: *mut libc::c_char, desc: *mut libc::c_char);
//pub static fn check_loop_level () -> i64;
/* Non-zero when a "break" instruction is encountered. */
- pub static posixly_correct :i32;
- static mut breaking : i32;
- static mut continuing : i32;
- static mut loop_level : i32;
- fn builtin_error(err:*const libc::c_char,...);
+ pub static posixly_correct: i32;
+ static mut breaking: i32;
+ static mut continuing: i32;
+ static mut loop_level: i32;
+ fn builtin_error(err: *const libc::c_char, ...);
}
#[no_mangle]
-pub extern "C" fn r_break_builtin(mut list :*mut WordList) -> i32 {
+pub extern "C" fn r_break_builtin(list: *mut WordList) -> i32 {
//println!("enter r_break_builtin");
- let mut newbreak : intmax_t = 1 as intmax_t;
+ let mut newbreak: intmax_t = 1 as intmax_t;
unsafe {
checkhelp(list);
//CHECK_HELPOPT! (list);
- if check_loop_level() == 0 {
- return EXECUTION_SUCCESS!();
- }
+ if check_loop_level() == 0 {
+ return EXECUTION_SUCCESS!();
+ }
get_numeric_arg(list, 1, &mut newbreak as *mut intmax_t);
- if newbreak <= 0{
- let mut tmp = CString::new("loop count ").unwrap();
- sh_erange ((*(*list).word).word, tmp.as_ptr() as * mut libc::c_char);
+ if newbreak <= 0 {
+ let tmp = CString::new("loop count ").unwrap();
+ sh_erange((*(*list).word).word, tmp.as_ptr() as *mut libc::c_char);
//set_breaking (get_loop_level());
- breaking = loop_level;
- return EXECUTION_FAILURE!();
- }
+ breaking = loop_level;
+ return EXECUTION_FAILURE!();
+ }
- if newbreak > loop_level as libc::c_long{
- newbreak = loop_level as i64;
- }
- breaking = newbreak as i32;
- // set_breaking(newbreak as i32);
- }
- return (EXECUTION_SUCCESS!());
+ if newbreak > loop_level as libc::c_long {
+ newbreak = loop_level as i64;
+ }
+ breaking = newbreak as i32;
+ // set_breaking(newbreak as i32);
+ }
+ return EXECUTION_SUCCESS!();
}
#[no_mangle]
-pub extern "C" fn r_continue_builtin (mut list :*mut WordList) -> i32 {
- let mut newcont : intmax_t = 0 as intmax_t;
+pub extern "C" fn r_continue_builtin(list: *mut WordList) -> i32 {
+ let mut newcont: intmax_t = 0 as intmax_t;
unsafe {
//CHECK_HELPOPT! (list);
checkhelp(list);
}
if check_loop_level() == 0 {
- return (EXECUTION_SUCCESS!());
+ return EXECUTION_SUCCESS!();
}
unsafe {
- get_numeric_arg(list, 1, &mut newcont as *mut intmax_t);
+ get_numeric_arg(list, 1, &mut newcont as *mut intmax_t);
}
unsafe {
- if newcont <= 0{
- let mut tmp = CString::new("loop count ").unwrap();
- sh_erange ((*(*list).word).word, tmp.as_ptr() as * mut libc::c_char);
- //set_breaking(get_loop_level());
- breaking = loop_level;
- return (EXECUTION_FAILURE!());
- }
- if newcont > loop_level.into(){
- newcont = loop_level as i64;
- }
- continuing = newcont as i32;
- //set_continuing(newcont as i32);
-
+ if newcont <= 0 {
+ let tmp = CString::new("loop count ").unwrap();
+ sh_erange((*(*list).word).word, tmp.as_ptr() as *mut libc::c_char);
+ //set_breaking(get_loop_level());
+ breaking = loop_level;
+ return EXECUTION_FAILURE!();
+ }
+ if newcont > loop_level.into() {
+ newcont = loop_level as i64;
+ }
+ continuing = newcont as i32;
+ //set_continuing(newcont as i32);
}
- return (EXECUTION_SUCCESS!());
+ return EXECUTION_SUCCESS!();
}
#[no_mangle]
-pub extern "C" fn check_loop_level () -> i32 {
-unsafe {
- if loop_level == 0 && posixly_correct == 0 {
- builtin_error (b"only meaningful in a `for`, `while`, or until `loop` \0" as *const u8 as *const libc::c_char);
- return 0;
- }
- loop_level
-}
+pub extern "C" fn check_loop_level() -> i32 {
+ unsafe {
+ if loop_level == 0 && posixly_correct == 0 {
+ builtin_error(
+ b"only meaningful in a `for`, `while`, or until `loop` \0" as *const u8
+ as *const libc::c_char,
+ );
+ return 0;
+ }
+ loop_level
+ }
}
-
diff --git a/bash-5.1/builtins_rust/build.rs b/bash-5.1/builtins_rust/build.rs
index ef4e40582b2ab1f45428e5ec56fc7ea28c399942..f17036b088d6a3e757652ca6cb1aaaef12b2e36f 100644
--- a/bash-5.1/builtins_rust/build.rs
+++ b/bash-5.1/builtins_rust/build.rs
@@ -1,24 +1,29 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
+use std::env;
- use std::{env};
-
- fn main() {
-
- let library_dir = "/opt/rsbash/builtins";
- let libsh_dir = "./lib/sh/";
- let exe_dir = "/opt/rsbash/";
-
- println!("cargo:rustc-link-search=native={}", env::join_paths(&[library_dir ]).unwrap().to_str().unwrap());
- println!("cargo:rustc-link-search=native={}", env::join_paths(&[ exe_dir]).unwrap().to_str().unwrap());
- println!("cargo:rustc-link-search=native={}", env::join_paths(&[ libsh_dir]).unwrap().to_str().unwrap());
-
- println!("cargo:rustc-link-args=-Wl,--copy-dt-needed-entries -fpic");
-
- println!("cargo:rustc-flags=-l static=sh");
- println!("cargo:rustc-flags=-l dylib=rt");
+fn main() {
+ let library_dir = "/opt/rsbash/builtins";
+ let libsh_dir = "./lib/sh/";
+ let exe_dir = "/opt/rsbash/";
-
- }
+ println!(
+ "cargo:rustc-link-search=native={}",
+ env::join_paths(&[library_dir]).unwrap().to_str().unwrap()
+ );
+ println!(
+ "cargo:rustc-link-search=native={}",
+ env::join_paths(&[exe_dir]).unwrap().to_str().unwrap()
+ );
+ println!(
+ "cargo:rustc-link-search=native={}",
+ env::join_paths(&[libsh_dir]).unwrap().to_str().unwrap()
+ );
+
+ println!("cargo:rustc-link-args=-Wl,--copy-dt-needed-entries -fpic");
+
+ println!("cargo:rustc-flags=-l static=sh");
+ println!("cargo:rustc-flags=-l dylib=rt");
+}
diff --git a/bash-5.1/builtins_rust/builtin.rs b/bash-5.1/builtins_rust/builtin.rs
new file mode 100644
index 0000000000000000000000000000000000000000..dbbe28c1c20d9798c26e68f445fa95fab203c92a
--- /dev/null
+++ b/bash-5.1/builtins_rust/builtin.rs
@@ -0,0 +1,19 @@
+
+ use std::{env};
+
+ fn main() {
+
+ let library_dir = "/opt/rsbash/builtins";
+ let libsh_dir = "./lib/sh/";
+ let exe_dir = "/opt/rsbash/";
+
+ println!("cargo:rustc-link-search=native={}", env::join_paths(&[library_dir ]).unwrap().to_str().unwrap());
+ println!("cargo:rustc-link-search=native={}", env::join_paths(&[ exe_dir]).unwrap().to_str().unwrap());
+ println!("cargo:rustc-link-search=native={}", env::join_paths(&[ libsh_dir]).unwrap().to_str().unwrap());
+
+ println!("cargo:rustc-link-args=-Wl,--copy-dt-needed-entries -fpic");
+
+ println!("cargo:rustc-flags=-l static=sh");
+ println!("cargo:rustc-flags=-l dylib=rt");
+
+ }
diff --git a/bash-5.1/builtins_rust/builtin/src/intercdep.rs b/bash-5.1/builtins_rust/builtin/src/intercdep.rs
index c7accbf57aa4d91e6f7ff0b01a893ffff57e9451..8cb09f10be32791bf233ca3a70e737f3f5e297cf 100644
--- a/bash-5.1/builtins_rust/builtin/src/intercdep.rs
+++ b/bash-5.1/builtins_rust/builtin/src/intercdep.rs
@@ -2,7 +2,7 @@
//# SPDX-License-Identifier: GPL-3.0-or-later
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordList, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
extern "C" {
static mut loption :*mut WordList;
diff --git a/bash-5.1/builtins_rust/builtin/src/lib.rs b/bash-5.1/builtins_rust/builtin/src/lib.rs
index c386304a3754241e2f8a23823a9d5f2a91549ca3..9d48413667af578ab80b40e530f9c422d3267023 100644
--- a/bash-5.1/builtins_rust/builtin/src/lib.rs
+++ b/bash-5.1/builtins_rust/builtin/src/lib.rs
@@ -1,14 +1,14 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char};
+use libc::{c_char, c_int};
use std::ffi::CStr;
include!(concat!("intercdep.rs"));
#[no_mangle]
pub extern "C" fn r_builtin_builtin(mut list: *mut WordList) -> i32 {
- unsafe{
- let mut function: Option:: = None;
+ unsafe {
+ let mut function: Option = None;
if no_options(list) != 0 {
return EX_USAGE;
}
@@ -16,7 +16,7 @@ pub extern "C" fn r_builtin_builtin(mut list: *mut WordList) -> i32 {
if list == std::ptr::null_mut() {
return EXECUTION_SUCCESS!();
}
- let mut command: &CStr = CStr::from_ptr((*(*list).word).word as *mut c_char);
+ let command: &CStr = CStr::from_ptr((*(*list).word).word as *mut c_char);
function = find_shell_builtin(command.as_ptr() as *mut c_char);
if function.is_none() {
sh_notbuiltin(command.as_ptr() as *mut c_char);
@@ -30,4 +30,3 @@ pub extern "C" fn r_builtin_builtin(mut list: *mut WordList) -> i32 {
};
}
}
-
diff --git a/bash-5.1/builtins_rust/caller/src/lib.rs b/bash-5.1/builtins_rust/caller/src/lib.rs
index 03f9a64c30da77716ddd8aea780ee2d259804808..dd7c4ae29af334e3b435c6b13ee31791c8b01b0f 100644
--- a/bash-5.1/builtins_rust/caller/src/lib.rs
+++ b/bash-5.1/builtins_rust/caller/src/lib.rs
@@ -1,33 +1,33 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate rread;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
-use libc::{c_char,c_int,PT_NULL,c_long,};
-use std::ffi::{CStr,CString};
+use libc::{c_char, c_int, c_long, PT_NULL};
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
+use std::ffi::{CStr, CString};
-use rread::{SHELL_VAR,ARRAY,intmax_t,};
use rhelp::r_builtin_help;
+use rread::{intmax_t, ARRAY, SHELL_VAR};
#[macro_export]
macro_rules! att_array {
- () => {
- 0x0000004 /* value is an array */
- }
+ () => {
+ 0x0000004 /* value is an array */
+ };
}
#[macro_export]
macro_rules! att_cell {
- ($var:expr) => {
- return (*($var).value) as *mut ARRAY;
- }
+ ($var:expr) => {
+ return (*($var).value) as *mut ARRAY;
+ };
}
// #[macro_export]
// macro_rules! array_empty {
-// ($a:expr) => {
+// ($a:expr) => {
// if (*($a)).num_elements == 0{
// return true;
// }
@@ -41,7 +41,6 @@ macro_rules! att_cell {
macro_rules! array_cell {
($var:expr) => {
(*($var)).value as *mut ARRAY
-
};
}
@@ -49,21 +48,21 @@ macro_rules! array_cell {
macro_rules! GET_ARRAY_FROM_VAR {
($n:expr,$v:expr,$a:expr) => {
$v = find_variable($n);
- if ($v) != std::ptr::null_mut() && array_p($v) != 0{
+ if ($v) != std::ptr::null_mut() && array_p($v) != 0 {
$a = array_cell!($v);
- }
- else{
+ } else {
$a = 0 as *mut ARRAY;
}
- }
+ };
}
-
-
#[macro_export]
macro_rules! CHECK_HELPOPT {
($l:expr) => {
- if $l != std::ptr::null_mut() && (*($l)).word != std::ptr::null_mut() && ISHELP((*(*($l)).word).word) == true{
+ if $l != std::ptr::null_mut()
+ && (*($l)).word != std::ptr::null_mut()
+ && ISHELP((*(*($l)).word).word) == true
+ {
r_builtin_help();
return EX_USAGE;
}
@@ -73,129 +72,125 @@ macro_rules! CHECK_HELPOPT {
type arrayind_t = intmax_t;
extern "C" {
- static loptend:*mut WordList;
+ static loptend: *mut WordList;
- fn find_variable(str:*const c_char)->*mut SHELL_VAR;
- fn array_reference(a:*mut ARRAY,i:arrayind_t)->*mut c_char;
+ fn find_variable(str: *const c_char) -> *mut SHELL_VAR;
+ fn array_reference(a: *mut ARRAY, i: arrayind_t) -> *mut c_char;
fn builtin_usage();
- fn no_options(list:*mut WordList)->i32;
- fn legal_number(string:*mut c_char,result:*mut c_long)->i32;
- fn sh_invalidnum(s:*mut c_char);
+ fn no_options(list: *mut WordList) -> i32;
+ fn legal_number(string: *mut c_char, result: *mut c_long) -> i32;
+ fn sh_invalidnum(s: *mut c_char);
}
-
-unsafe fn STREQ(a:*const c_char,b:*const c_char)->bool{
- return *a == *b && libc::strcmp(a,b) == 0;
+unsafe fn STREQ(a: *const c_char, b: *const c_char) -> bool {
+ return *a == *b && libc::strcmp(a, b) == 0;
}
-unsafe fn ISHELP(s:*const c_char)->bool{
+unsafe fn ISHELP(s: *const c_char) -> bool {
// let s_str = CString::new("--help").unwrap().as_ptr();
- return STREQ( s,CString::new("--help").unwrap().as_ptr());
+ return STREQ(s, CString::new("--help").unwrap().as_ptr());
}
-unsafe fn array_p(var:*mut SHELL_VAR) ->i32 {
+unsafe fn array_p(var: *mut SHELL_VAR) -> i32 {
return (*var).attributes & att_array!();
}
-unsafe fn array_empty(a:*mut ARRAY)->bool{
-
- if (*a).num_elements == 0{
+unsafe fn array_empty(a: *mut ARRAY) -> bool {
+ if (*a).num_elements == 0 {
return true;
+ } else {
+ return false;
}
- else{
- return false ;
- }
-
}
//rust
#[no_mangle]
-pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{
- let funcname_v:*mut SHELL_VAR ;
- let bash_source_v:*mut SHELL_VAR;
- let bash_lineno_v:*mut SHELL_VAR;
- let funcname_a:*mut ARRAY;
- let bash_source_a:*mut ARRAY;
- let bash_lineno_a:*mut ARRAY;
- let funcname_s:*mut c_char;
- let mut source_s:*mut c_char;
- let mut lineno_s:*mut c_char;
- let mut num:intmax_t = 0;
-
- let mut c_str :CString;
-
- unsafe{
+pub extern "C" fn r_caller_builtin(mut list: *mut WordList) -> i32 {
+ let funcname_v: *mut SHELL_VAR;
+ let bash_source_v: *mut SHELL_VAR;
+ let bash_lineno_v: *mut SHELL_VAR;
+ let funcname_a: *mut ARRAY;
+ let bash_source_a: *mut ARRAY;
+ let bash_lineno_a: *mut ARRAY;
+ let funcname_s: *mut c_char;
+ let mut source_s: *mut c_char;
+ let mut lineno_s: *mut c_char;
+ let mut num: intmax_t = 0;
+
+ let mut c_str: CString;
+
+ unsafe {
CHECK_HELPOPT!(list);
let c_str1 = CString::new("FUNCNAME").unwrap();
let c_ptr1 = c_str1.as_ptr();
- GET_ARRAY_FROM_VAR!(c_ptr1,funcname_v,funcname_a);
+ GET_ARRAY_FROM_VAR!(c_ptr1, funcname_v, funcname_a);
// GET_ARRAY_FROM_VAR!(CString::new("FUNCNAME").unwrap().as_ptr(),funcname_v,funcname_a);
let c_str1 = CString::new("BASH_SOURCE").unwrap();
let c_ptr1 = c_str1.as_ptr();
- GET_ARRAY_FROM_VAR!(c_ptr1,bash_source_v,bash_source_a);
+ GET_ARRAY_FROM_VAR!(c_ptr1, bash_source_v, bash_source_a);
// GET_ARRAY_FROM_VAR!(CString::new("BASH_SOURCE").unwrap().as_ptr(),bash_source_v,bash_source_a);
let c_str1 = CString::new("BASH_LINENO").unwrap();
let c_ptr1 = c_str1.as_ptr();
- GET_ARRAY_FROM_VAR!(c_ptr1,bash_lineno_v,bash_lineno_a);
+ GET_ARRAY_FROM_VAR!(c_ptr1, bash_lineno_v, bash_lineno_a);
// GET_ARRAY_FROM_VAR!(CString::new("BASH_LINENO").unwrap().as_ptr(),bash_lineno_v,bash_lineno_a);
- if bash_lineno_a.is_null() || array_empty(bash_lineno_a){
+ if bash_lineno_a.is_null() || array_empty(bash_lineno_a) {
return EXECUTION_FAILURE!();
}
-
- if bash_source_a.is_null() || array_empty(bash_source_a){
+
+ if bash_source_a.is_null() || array_empty(bash_source_a) {
return EXECUTION_FAILURE!();
}
-
- if no_options(list) != 0{
+
+ if no_options(list) != 0 {
return EX_USAGE;
}
- list = loptend; /* skip over possible `--' */
+ list = loptend; /* skip over possible `--' */
/* If there is no argument list, then give short form: line filename. */
if list.is_null() {
- lineno_s = array_reference(bash_lineno_a,0);
- source_s = array_reference(bash_source_a,1);
-
- if !lineno_s.is_null(){
+ lineno_s = array_reference(bash_lineno_a, 0);
+ source_s = array_reference(bash_source_a, 1);
+
+ if !lineno_s.is_null() {
lineno_s = lineno_s;
- }
- else{
+ } else {
c_str = CString::new("NULL").unwrap();
lineno_s = c_str.as_ptr() as *mut c_char;
}
- if !source_s.is_null(){
+ if !source_s.is_null() {
source_s = source_s;
- }
- else{
+ } else {
c_str = CString::new("NULL").unwrap();
source_s = c_str.as_ptr() as *mut c_char;
}
let lineno_s_str = CStr::from_ptr(lineno_s).to_str().unwrap().to_owned();
let source_s_str = CStr::from_ptr(source_s).to_str().unwrap().to_owned();
- println!("{} {}",lineno_s_str,source_s_str);
+ println!("{} {}", lineno_s_str, source_s_str);
- return EXECUTION_SUCCESS!();
+ return EXECUTION_SUCCESS!();
}
if funcname_a.is_null() || array_empty(funcname_a) {
return EXECUTION_FAILURE!();
}
- if legal_number((*(*list).word).word,&mut num) != 0{
- lineno_s = array_reference(bash_lineno_a,num);
- source_s = array_reference(bash_source_a,num+1);
- funcname_s = array_reference(funcname_a,num+1);
-
- if lineno_s == PT_NULL as *mut c_char || source_s == PT_NULL as *mut c_char || funcname_s == PT_NULL as *mut c_char{
+ if legal_number((*(*list).word).word, &mut num) != 0 {
+ lineno_s = array_reference(bash_lineno_a, num);
+ source_s = array_reference(bash_source_a, num + 1);
+ funcname_s = array_reference(funcname_a, num + 1);
+
+ if lineno_s == PT_NULL as *mut c_char
+ || source_s == PT_NULL as *mut c_char
+ || funcname_s == PT_NULL as *mut c_char
+ {
return EXECUTION_FAILURE!();
}
let lineno_s_str = CStr::from_ptr(lineno_s).to_str().unwrap().to_owned();
let funcname_s_str = CStr::from_ptr(funcname_s).to_str().unwrap().to_owned();
let source_s_str = CStr::from_ptr(source_s).to_str().unwrap().to_owned();
- println!("{} {} {}",lineno_s_str,funcname_s_str,source_s_str);
- }
- else{
+ println!("{} {} {}", lineno_s_str, funcname_s_str, source_s_str);
+ } else {
sh_invalidnum((*(*list).word).word);
builtin_usage();
return EX_USAGE;
@@ -204,5 +199,3 @@ pub extern "C" fn r_caller_builtin(mut list:*mut WordList)->i32{
return EXECUTION_SUCCESS!();
}
}
-
-
diff --git a/bash-5.1/builtins_rust/cd/src/lib.rs b/bash-5.1/builtins_rust/cd/src/lib.rs
index d36749360275337daed7f970b1f81a6c40cb1632..f7ccfe3fd8b2075add0f314b4394a5abd846faa0 100644
--- a/bash-5.1/builtins_rust/cd/src/lib.rs
+++ b/bash-5.1/builtins_rust/cd/src/lib.rs
@@ -1,13 +1,13 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use libc::{c_char, c_long, c_void};
-use std::{ffi::{CString, CStr}};
use rhelp::r_builtin_help;
+use std::ffi::{CStr, CString};
#[repr(i8)]
pub enum JOB_STATE {
@@ -15,826 +15,914 @@ pub enum JOB_STATE {
JRUNNING = 1,
JSTOPPED = 2,
JDEAD = 4,
- JMIXED = 8
+ JMIXED = 8,
}
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub struct PROCESS {
next: *mut PROCESS,
- pid:libc::c_int,
- status:libc::c_int,
- running:libc::c_int,
- command:*mut c_char
+ pid: libc::c_int,
+ status: libc::c_int,
+ running: libc::c_int,
+ command: *mut c_char,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub union REDIRECTEE {
- dest:libc::c_int,
- filename:* mut WordDesc
+ dest: libc::c_int,
+ filename: *mut WordDesc,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT, /* Next element, or NULL. */
- redirector:REDIRECTEE, /* Descriptor or varname to be redirected. */
- rflags:libc::c_int, /* Private flags for this redirection */
- flags:libc::c_int, /* Flag value for `open'. */
- instruction:r_instruction, /* What to do with the information. */
- redirectee:REDIRECTEE, /* File descriptor or filename */
- here_doc_eof:*mut c_char /* The word that appeared in <*mut SHELL_VAR, /* Function called to return a `dynamic'
- value for a variable, like $SECONDS
- or $RANDOM. */
- assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut c_char,t:c_long,str2:* mut c_char)->*mut SHELL_VAR, /* Function called when this `special
- variable' is assigned a value in
- bind_variable. */
- attributes:i32, /* export, readonly, array, invisible... */
- context:i32 /* Which context this variable belongs to. */
+ name: *mut c_char, /* Symbol that the user types. */
+ value: *mut c_char, /* Value that is returned. */
+ exportstr: *mut c_char, /* String for the environment. */
+ dynamic_value: *mut fn(v: *mut SHELL_VAR) -> *mut SHELL_VAR, /* Function called to return a `dynamic'
+ value for a variable, like $SECONDS
+ or $RANDOM. */
+ assign_func: *mut fn(
+ v: *mut SHELL_VAR,
+ str1: *mut c_char,
+ t: c_long,
+ str2: *mut c_char,
+ ) -> *mut SHELL_VAR, /* Function called when this `special
+ variable' is assigned a value in
+ bind_variable. */
+ attributes: i32, /* export, readonly, array, invisible... */
+ context: i32, /* Which context this variable belongs to. */
}
-
#[macro_export]
macro_rules! DUP_JOB {
- () => {-2}
+ () => {
+ -2
+ };
}
#[macro_export]
macro_rules! readonly_p {
- ($var:expr) => {
- (*$var).attributes & 0x0000002
- }
+ ($var:expr) => {
+ (*$var).attributes & 0x0000002
+ };
}
#[macro_export]
macro_rules! exported_p {
- ($var:expr) => {
- (*$var).attributes & 0x0000001
- }
+ ($var:expr) => {
+ (*$var).attributes & 0x0000001
+ };
}
#[macro_export]
macro_rules! LCD_DOVARS {
- () => {
- 0x001
- }
+ () => {
+ 0x001
+ };
}
#[macro_export]
macro_rules! LCD_DOSPELL {
- () => {
- 0x002
- }
+ () => {
+ 0x002
+ };
}
#[macro_export]
macro_rules! LCD_PRINTPATH {
- () => {
- 0x004
- }
+ () => {
+ 0x004
+ };
}
#[macro_export]
macro_rules! LCD_FREEDIRNAME {
- () => {
- 0x008
- }
+ () => {
+ 0x008
+ };
}
#[macro_export]
macro_rules! MP_DOTILDE {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
macro_rules! PATH_CHECKDOTDOT {
- () => {
- 0x0001
- }
+ () => {
+ 0x0001
+ };
}
#[macro_export]
macro_rules! PATH_CHECKEXISTS {
- () => {
- 0x0002
- }
+ () => {
+ 0x0002
+ };
}
#[macro_export]
macro_rules! errno {
- () => {
- *libc::__errno_location()
- }
+ () => {
+ *libc::__errno_location()
+ };
}
extern "C" {
- fn builtin_error(err:*const c_char,...);
-
- static mut loptend:*mut WordList;
-
- static mut array_needs_making:i32;
- fn bind_variable ( lhs:*const c_char, rhs:* mut c_char, i:i32)->* mut SHELL_VAR;
- fn update_export_env_inplace (env_prefix:* mut c_char, preflen:i32, value:* mut c_char);
- static mut the_current_working_directory:* mut c_char;
- fn get_working_directory (for_whom:* mut c_char)->* mut c_char;
- fn sh_physpath (path:*mut c_char, flags:i32)->* mut c_char;
- fn sh_chkwrite (s:i32)->i32;
- fn get_string_value (var_name:*const c_char)->* mut c_char;
-
- static mut restricted:i32;
- fn sh_restricted (s:*mut c_char);
- static no_symbolic_links:i32;
-
+ fn builtin_error(err: *const c_char, ...);
+
+ static mut loptend: *mut WordList;
+
+ static mut array_needs_making: i32;
+ fn bind_variable(lhs: *const c_char, rhs: *mut c_char, i: i32) -> *mut SHELL_VAR;
+ fn update_export_env_inplace(env_prefix: *mut c_char, preflen: i32, value: *mut c_char);
+ static mut the_current_working_directory: *mut c_char;
+ fn get_working_directory(for_whom: *mut c_char) -> *mut c_char;
+ fn sh_physpath(path: *mut c_char, flags: i32) -> *mut c_char;
+ fn sh_chkwrite(s: i32) -> i32;
+ fn get_string_value(var_name: *const c_char) -> *mut c_char;
+
+ static mut restricted: i32;
+ fn sh_restricted(s: *mut c_char);
+ static no_symbolic_links: i32;
+
fn reset_internal_getopt();
- fn internal_getopt (list:*mut WordList , opts:*mut c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
fn builtin_usage();
- static cdable_vars:i32;
- static interactive:i32;
- static cdspelling:i32;
- fn absolute_pathname (str:*const c_char)->i32;
- fn extract_colon_unit (string:*mut c_char, p_index:*mut i32)->* mut c_char;
- fn sh_makepath (path:*const c_char, dir:*const c_char, flags:i32)->* mut c_char;
- static privileged_mode:i32;
- fn dirspell (dirname:* mut c_char)->* mut c_char;
- fn printable_filename (fnc:* mut c_char, flags:i32)->* mut c_char;
-
- static posixly_correct:i32;
- fn same_file (path1:*const c_char, path2:*const c_char, stp1:*mut libc::stat, stp2:*mut libc::stat)->i32;
- fn make_absolute (str1:*const c_char, dot_path:*const c_char)->* mut c_char;
- fn sh_canonpath (path:* mut c_char, flags:i32)->* mut c_char;
- fn set_working_directory (path:* mut c_char);
-
-}
-
-pub static mut xattrfd:i32=-1;
-pub static mut xattrflag:i32=0;
-pub static mut verbatim_pwd:i32=0;
-pub static mut eflag:i32=0;
+ static cdable_vars: i32;
+ static interactive: i32;
+ static cdspelling: i32;
+ fn absolute_pathname(str: *const c_char) -> i32;
+ fn extract_colon_unit(string: *mut c_char, p_index: *mut i32) -> *mut c_char;
+ fn sh_makepath(path: *const c_char, dir: *const c_char, flags: i32) -> *mut c_char;
+ static privileged_mode: i32;
+ fn dirspell(dirname: *mut c_char) -> *mut c_char;
+ fn printable_filename(fnc: *mut c_char, flags: i32) -> *mut c_char;
+
+ static posixly_correct: i32;
+ fn same_file(
+ path1: *const c_char,
+ path2: *const c_char,
+ stp1: *mut libc::stat,
+ stp2: *mut libc::stat,
+ ) -> i32;
+ fn make_absolute(str1: *const c_char, dot_path: *const c_char) -> *mut c_char;
+ fn sh_canonpath(path: *mut c_char, flags: i32) -> *mut c_char;
+ fn set_working_directory(path: *mut c_char);
+
+}
+
+pub static mut xattrfd: i32 = -1;
+pub static mut xattrflag: i32 = 0;
+pub static mut verbatim_pwd: i32 = 0;
+pub static mut eflag: i32 = 0;
/* How to bring a job into the foreground. */
#[no_mangle]
-pub extern "C" fn r_setpwd (dirname:* mut c_char)->i32
-{
- let old_anm:i32;
- let tvar:* mut SHELL_VAR;
- unsafe {
- old_anm = array_needs_making;
-
- let c_str_pwd = CString::new("PWD").unwrap();
- if dirname ==std::ptr::null_mut() {
- tvar=bind_variable (c_str_pwd.as_ptr(), CString::new("").unwrap().as_ptr() as * mut c_char, 0);
- } else {
- tvar = bind_variable (c_str_pwd.as_ptr(), dirname , 0);
- }
-
- if tvar !=std::ptr::null_mut() && readonly_p! (tvar) !=0 {
- return EXECUTION_FAILURE!();
- }
-
- if tvar !=std::ptr::null_mut() && old_anm == 0 && array_needs_making !=0 && exported_p !(tvar) !=0 {
- if dirname ==std::ptr::null_mut() {
- update_export_env_inplace (c_str_pwd.as_ptr() as * mut c_char, 4, CString::new("").unwrap().as_ptr() as * mut c_char);
- } else {
- update_export_env_inplace (c_str_pwd.as_ptr() as * mut c_char, 4, dirname);
+pub extern "C" fn r_setpwd(dirname: *mut c_char) -> i32 {
+ let old_anm: i32;
+ let tvar: *mut SHELL_VAR;
+ unsafe {
+ old_anm = array_needs_making;
+
+ let c_str_pwd = CString::new("PWD").unwrap();
+ if dirname == std::ptr::null_mut() {
+ tvar = bind_variable(
+ c_str_pwd.as_ptr(),
+ CString::new("").unwrap().as_ptr() as *mut c_char,
+ 0,
+ );
+ } else {
+ tvar = bind_variable(c_str_pwd.as_ptr(), dirname, 0);
+ }
+
+ if tvar != std::ptr::null_mut() && readonly_p!(tvar) != 0 {
+ return EXECUTION_FAILURE!();
+ }
+
+ if tvar != std::ptr::null_mut()
+ && old_anm == 0
+ && array_needs_making != 0
+ && exported_p!(tvar) != 0
+ {
+ if dirname == std::ptr::null_mut() {
+ update_export_env_inplace(
+ c_str_pwd.as_ptr() as *mut c_char,
+ 4,
+ CString::new("").unwrap().as_ptr() as *mut c_char,
+ );
+ } else {
+ update_export_env_inplace(c_str_pwd.as_ptr() as *mut c_char, 4, dirname);
+ }
+ array_needs_making = 0;
+ }
+ return EXECUTION_SUCCESS!();
}
- array_needs_making = 0;
- }
- return EXECUTION_SUCCESS!();
- }
}
#[no_mangle]
-pub extern "C" fn r_bindpwd (no_symlinks:i32)->i32 {
- let mut dirname:*mut c_char;
- let pwdvar:*mut c_char;
- let old_anm:i32;
- let mut r:i32;
- let mut canon_failed:i32;
- let tvar:* mut SHELL_VAR;
- unsafe {
- r = sh_chkwrite (EXECUTION_SUCCESS!());
- if the_current_working_directory !=std::ptr::null_mut() {
- if no_symlinks !=0{
- dirname=sh_physpath (the_current_working_directory, 0);
- }else {
- dirname =the_current_working_directory;
+pub extern "C" fn r_bindpwd(no_symlinks: i32) -> i32 {
+ let mut dirname: *mut c_char;
+ let pwdvar: *mut c_char;
+ let old_anm: i32;
+ let mut r: i32;
+ let mut canon_failed: i32;
+ let tvar: *mut SHELL_VAR;
+ unsafe {
+ r = sh_chkwrite(EXECUTION_SUCCESS!());
+ if the_current_working_directory != std::ptr::null_mut() {
+ if no_symlinks != 0 {
+ dirname = sh_physpath(the_current_working_directory, 0);
+ } else {
+ dirname = the_current_working_directory;
+ }
+ } else {
+ let c_str_cd = CString::new("cd").unwrap();
+ dirname = get_working_directory(c_str_cd.as_ptr() as *mut c_char);
+ }
+
+ /* If canonicalization fails, reset dirname to the_current_working_directory */
+ canon_failed = 0;
+ if dirname == std::ptr::null_mut() {
+ canon_failed = 1;
+ dirname = the_current_working_directory;
+ }
+
+ old_anm = array_needs_making;
+ let c_str_pwd = CString::new("PWD").unwrap();
+ pwdvar = get_string_value(c_str_pwd.as_ptr());
+
+ tvar = bind_variable(CString::new("OLDPWD").unwrap().as_ptr(), pwdvar, 0);
+ if tvar != std::ptr::null_mut() && readonly_p!(tvar) != 0 {
+ r = EXECUTION_FAILURE!();
+ }
+
+ if old_anm == 0 && array_needs_making != 0 && exported_p!(tvar) != 0 {
+ update_export_env_inplace(
+ CString::new("OLDPWD").unwrap().as_ptr() as *mut c_char,
+ 7,
+ pwdvar,
+ );
+ array_needs_making = 0;
+ }
+
+ if r_setpwd(dirname) == EXECUTION_FAILURE!() {
+ r = EXECUTION_FAILURE!();
+ }
+
+ if canon_failed != 0 && eflag != 0 {
+ r = EXECUTION_FAILURE!();
+ }
+
+ if dirname != std::ptr::null_mut() && dirname != the_current_working_directory {
+ libc::free(dirname as *mut libc::c_void);
+ }
+ return r;
}
- } else {
- let c_str_cd = CString::new("cd").unwrap();
- dirname=get_working_directory(c_str_cd.as_ptr() as * mut c_char);
- }
-
- /* If canonicalization fails, reset dirname to the_current_working_directory */
- canon_failed = 0;
- if dirname == std::ptr::null_mut() {
- canon_failed = 1;
- dirname = the_current_working_directory;
- }
-
- old_anm = array_needs_making;
- let c_str_pwd = CString::new("PWD").unwrap();
- pwdvar = get_string_value (c_str_pwd.as_ptr());
-
- tvar = bind_variable (CString::new("OLDPWD").unwrap().as_ptr(), pwdvar, 0);
- if tvar !=std::ptr::null_mut() && readonly_p! (tvar) !=0{
- r = EXECUTION_FAILURE!();
- }
-
- if old_anm == 0 && array_needs_making !=0 && exported_p! (tvar) !=0 {
- update_export_env_inplace (CString::new("OLDPWD").unwrap().as_ptr() as * mut c_char, 7, pwdvar);
- array_needs_making = 0;
- }
-
- if r_setpwd (dirname) == EXECUTION_FAILURE!() {
- r = EXECUTION_FAILURE!();
- }
-
- if canon_failed !=0 && eflag !=0 {
- r = EXECUTION_FAILURE!();
- }
-
- if dirname !=std::ptr::null_mut() && dirname != the_current_working_directory {
- libc::free(dirname as * mut libc::c_void);
- }
- return r;
- }
}
/* Call get_working_directory to reset the value of
- the_current_working_directory () */
+the_current_working_directory () */
#[no_mangle]
-pub extern "C" fn r_resetpwd (caller:*mut c_char)->*mut c_char {
- let tdir:*mut c_char;
- unsafe {
- libc::free(the_current_working_directory as * mut libc::c_void);
- the_current_working_directory = 0 as * mut c_char;
- tdir = get_working_directory (caller);
- return tdir;
- }
+pub extern "C" fn r_resetpwd(caller: *mut c_char) -> *mut c_char {
+ let tdir: *mut c_char;
+ unsafe {
+ libc::free(the_current_working_directory as *mut libc::c_void);
+ the_current_working_directory = 0 as *mut c_char;
+ tdir = get_working_directory(caller);
+ return tdir;
+ }
}
#[no_mangle]
-pub extern "C" fn r_cdxattr (dir: *mut c_char, ndirp:*mut c_char)->i32 {
- return -1;
+pub extern "C" fn r_cdxattr(dir: *mut c_char, ndirp: *mut c_char) -> i32 {
+ return -1;
}
#[no_mangle]
-pub extern "C" fn r_resetxattr () {
- unsafe {
- xattrfd = -1; /* not strictly necessary */
- }
+pub extern "C" fn r_resetxattr() {
+ unsafe {
+ xattrfd = -1; /* not strictly necessary */
+ }
}
#[no_mangle]
-pub extern "C" fn r_cd_builtin (mut list:*mut WordList)->i32 {
- let mut dirname:*mut c_char=std::ptr::null_mut();
- let cdpath:*mut c_char;
- let mut path:*mut c_char;
- let mut temp:*mut c_char;
- let mut path_index:i32;
- let mut no_symlinks:i32;
- let mut opt:i32;
- let mut lflag:i32;
- let e:i32;
-
- unsafe {
- if restricted !=0 {
- sh_restricted (0 as * mut c_char);
- return EXECUTION_FAILURE!();
- }
+pub extern "C" fn r_cd_builtin(mut list: *mut WordList) -> i32 {
+ let mut dirname: *mut c_char = std::ptr::null_mut();
+ let cdpath: *mut c_char;
+ let mut path: *mut c_char;
+ let mut temp: *mut c_char;
+ let mut path_index: i32;
+ let mut no_symlinks: i32;
+ let mut opt: i32;
+ let mut lflag: i32;
+ let e: i32;
+
+ unsafe {
+ if restricted != 0 {
+ sh_restricted(0 as *mut c_char);
+ return EXECUTION_FAILURE!();
+ }
- eflag = 0;
- no_symlinks = no_symbolic_links;
- xattrflag = 0;
- reset_internal_getopt ();
-
- let c_str_elp = CString::new("eLP").unwrap(); // from a &str, creates a new allocation
- opt = internal_getopt (list, c_str_elp.as_ptr() as * mut c_char);
- while opt != -1 {
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
- match optChar {
- 'P'=>{no_symlinks = 1;}
- 'L'=>{no_symlinks = 0;}
- 'e'=>{eflag = 1;}
- _=>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
- }
- builtin_usage ();
- return EX_USAGE;
+ eflag = 0;
+ no_symlinks = no_symbolic_links;
+ xattrflag = 0;
+ reset_internal_getopt();
+
+ let c_str_elp = CString::new("eLP").unwrap(); // from a &str, creates a new allocation
+ opt = internal_getopt(list, c_str_elp.as_ptr() as *mut c_char);
+ while opt != -1 {
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'P' => {
+ no_symlinks = 1;
+ }
+ 'L' => {
+ no_symlinks = 0;
+ }
+ 'e' => {
+ eflag = 1;
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
+ return EX_USAGE;
+ }
}
- }
- opt =internal_getopt (list, c_str_elp.as_ptr() as * mut c_char);
- }
+ opt = internal_getopt(list, c_str_elp.as_ptr() as *mut c_char);
+ }
- // list = loptend; //后加的
+ // list = loptend; //后加的
- if cdable_vars != 0 {
- lflag=LCD_DOVARS!();
- } else {
- lflag=0;
- }
+ if cdable_vars != 0 {
+ lflag = LCD_DOVARS!();
+ } else {
+ lflag = 0;
+ }
- if interactive !=0 && cdspelling !=0 {
- lflag=lflag | LCD_DOSPELL!();
- } else {
- lflag=lflag | 0;
- }
+ if interactive != 0 && cdspelling != 0 {
+ lflag = lflag | LCD_DOSPELL!();
+ } else {
+ lflag = lflag | 0;
+ }
- if eflag !=0 && no_symlinks == 0{
- eflag = 0;
- }
+ if eflag != 0 && no_symlinks == 0 {
+ eflag = 0;
+ }
- if loptend == std::ptr::null_mut() {
- /* `cd' without arguments is equivalent to `cd $HOME' */
- dirname = get_string_value (CString::new("HOME").unwrap().as_ptr());
+ if loptend == std::ptr::null_mut() {
+ /* `cd' without arguments is equivalent to `cd $HOME' */
+ dirname = get_string_value(CString::new("HOME").unwrap().as_ptr());
- if dirname == std::ptr::null_mut() {
- builtin_error (CString::new("HOME not set").unwrap().as_ptr());
- return EXECUTION_FAILURE!();
- }
- lflag = 0;
- }
- else if (*loptend).next != std::ptr::null_mut() {
- builtin_error (CString::new("too many arguments").unwrap().as_ptr());
- return EXECUTION_FAILURE!();
- }
- else if char::from((*(*(*loptend).word).word) as u8) == '-' && char::from(*((((*(*loptend).word).word) as usize +4) as *mut c_char) as u8) == '\0' {
- /* This is `cd -', equivalent to `cd $OLDPWD' */
- dirname = get_string_value (CString::new("OLDPWD").unwrap().as_ptr());
- if dirname == std::ptr::null_mut() {
- builtin_error (CString::new("OLDPWD not set").unwrap().as_ptr());
- return EXECUTION_FAILURE!();
- }
- lflag = LCD_PRINTPATH!(); /* According to SUSv3 */
- }
- else if absolute_pathname ((*(*loptend).word).word) !=0 {
- dirname = (*(*loptend).word).word;
- }
- else if privileged_mode == 0 && get_string_value (CString::new("CDPATH").unwrap().as_ptr() ) != std::ptr::null_mut(){
- cdpath = get_string_value (CString::new("CDPATH").unwrap().as_ptr() );
- dirname = (*(*loptend).word).word;
-
- /* Find directory in $CDPATH. */
- path_index = 0;
- path = extract_colon_unit (cdpath, & mut path_index);
-
- while path != std::ptr::null_mut() {
- /* OPT is 1 if the path element is non-empty */
- opt = (char::from(*path as u8 )!= '\0') as i32 ;
- temp = sh_makepath (path, dirname, MP_DOTILDE!());
- libc::free (path as * mut c_void);
-
- if r_change_to_directory (temp, no_symlinks, xattrflag) !=0 {
- /* POSIX.2 says that if a nonempty directory from CDPATH
- is used to find the directory to change to, the new
- directory name is echoed to stdout, whether or not
- the shell is interactive. */
- if opt !=0 {
- if no_symlinks !=0 {
- path=temp;
- }
- else {
- path=the_current_working_directory;
+ if dirname == std::ptr::null_mut() {
+ builtin_error(CString::new("HOME not set").unwrap().as_ptr());
+ return EXECUTION_FAILURE!();
+ }
+ lflag = 0;
+ } else if (*loptend).next != std::ptr::null_mut() {
+ builtin_error(CString::new("too many arguments").unwrap().as_ptr());
+ return EXECUTION_FAILURE!();
+ } else if char::from((*(*(*loptend).word).word) as u8) == '-'
+ && char::from(*((((*(*loptend).word).word) as usize + 4) as *mut c_char) as u8) == '\0'
+ {
+ /* This is `cd -', equivalent to `cd $OLDPWD' */
+ dirname = get_string_value(CString::new("OLDPWD").unwrap().as_ptr());
+ if dirname == std::ptr::null_mut() {
+ builtin_error(CString::new("OLDPWD not set").unwrap().as_ptr());
+ return EXECUTION_FAILURE!();
+ }
+ lflag = LCD_PRINTPATH!(); /* According to SUSv3 */
+ } else if absolute_pathname((*(*loptend).word).word) != 0 {
+ dirname = (*(*loptend).word).word;
+ } else if privileged_mode == 0
+ && get_string_value(CString::new("CDPATH").unwrap().as_ptr()) != std::ptr::null_mut()
+ {
+ cdpath = get_string_value(CString::new("CDPATH").unwrap().as_ptr());
+ dirname = (*(*loptend).word).word;
+
+ /* Find directory in $CDPATH. */
+ path_index = 0;
+ path = extract_colon_unit(cdpath, &mut path_index);
+
+ while path != std::ptr::null_mut() {
+ /* OPT is 1 if the path element is non-empty */
+ opt = (char::from(*path as u8) != '\0') as i32;
+ temp = sh_makepath(path, dirname, MP_DOTILDE!());
+ libc::free(path as *mut c_void);
+
+ if r_change_to_directory(temp, no_symlinks, xattrflag) != 0 {
+ /* POSIX.2 says that if a nonempty directory from CDPATH
+ is used to find the directory to change to, the new
+ directory name is echoed to stdout, whether or not
+ the shell is interactive. */
+ if opt != 0 {
+ if no_symlinks != 0 {
+ path = temp;
+ } else {
+ path = the_current_working_directory;
+ }
+
+ if path != std::ptr::null_mut() {
+ libc::printf(
+ CString::new("%s\n").unwrap().as_ptr() as *const c_char,
+ path,
+ );
+ }
+ }
+
+ libc::free(temp as *mut c_void);
+ return r_bindpwd(no_symlinks);
+ } else {
+ libc::free(temp as *mut c_void);
+ }
+
+ path = extract_colon_unit(cdpath, &mut path_index);
}
+ } else {
+ dirname = (*(*loptend).word).word;
+ }
- if path !=std::ptr::null_mut() {
- libc::printf(CString::new("%s\n").unwrap().as_ptr() as * const c_char,path);
+ /* When we get here, DIRNAME is the directory to change to. If we
+ chdir successfully, just return. */
+ if 0 != r_change_to_directory(dirname, no_symlinks, xattrflag) {
+ if (lflag & LCD_PRINTPATH!()) != 0 {
+ libc::printf(
+ CString::new("%s\n").unwrap().as_ptr() as *const c_char,
+ dirname,
+ );
}
- }
-
- libc::free (temp as * mut c_void);
- return r_bindpwd (no_symlinks);
- }
- else {
- libc::free (temp as * mut c_void);
- }
-
- path = extract_colon_unit (cdpath, &mut path_index);
- }
- }
- else{
- dirname = (*(*loptend).word).word;
- }
+ return r_bindpwd(no_symlinks);
+ }
+ /* If the user requests it, then perhaps this is the name of
+ a shell variable, whose value contains the directory to
+ change to. */
+ if (lflag & LCD_DOVARS!()) != 0 {
+ temp = get_string_value(dirname);
+ if temp != std::ptr::null_mut()
+ && r_change_to_directory(temp, no_symlinks, xattrflag) != 0
+ {
+ libc::printf(
+ CString::new("%s\n").unwrap().as_ptr() as *const c_char,
+ temp,
+ );
+ return r_bindpwd(no_symlinks);
+ }
+ }
- /* When we get here, DIRNAME is the directory to change to. If we
- chdir successfully, just return. */
- if 0 != r_change_to_directory (dirname, no_symlinks, xattrflag) {
- if (lflag & LCD_PRINTPATH!()) !=0 {
- libc::printf(CString::new("%s\n").unwrap().as_ptr() as * const c_char,dirname);
- }
- return r_bindpwd (no_symlinks);
- }
+ /* If the user requests it, try to find a directory name similar in
+ spelling to the one requested, in case the user made a simple
+ typo. This is similar to the UNIX 8th and 9th Edition shells. */
+ if (lflag & LCD_DOSPELL!()) != 0 {
+ temp = dirspell(dirname);
+ if temp != std::ptr::null_mut()
+ && r_change_to_directory(temp, no_symlinks, xattrflag) != 0
+ {
+ println!("{:?}", temp);
+ libc::free(temp as *mut c_void);
+ return r_bindpwd(no_symlinks);
+ } else {
+ libc::free(temp as *mut c_void);
+ }
+ }
- /* If the user requests it, then perhaps this is the name of
- a shell variable, whose value contains the directory to
- change to. */
- if (lflag & LCD_DOVARS!()) !=0 {
- temp = get_string_value (dirname);
- if temp != std::ptr::null_mut() && r_change_to_directory (temp, no_symlinks, xattrflag) !=0 {
- libc::printf(CString::new("%s\n").unwrap().as_ptr() as * const c_char,temp);
- return r_bindpwd (no_symlinks);
- }
- }
+ e = errno!();
+ temp = printable_filename(dirname, 0);
+ builtin_error(
+ CString::new("%s: %s").unwrap().as_ptr(),
+ temp,
+ libc::strerror(e),
+ );
- /* If the user requests it, try to find a directory name similar in
- spelling to the one requested, in case the user made a simple
- typo. This is similar to the UNIX 8th and 9th Edition shells. */
- if (lflag & LCD_DOSPELL!()) !=0 {
- temp = dirspell (dirname);
- if temp !=std::ptr::null_mut() && r_change_to_directory (temp, no_symlinks, xattrflag) !=0 {
- println!("{:?}", temp);
- libc::free (temp as * mut c_void);
- return r_bindpwd (no_symlinks);
- } else {
- libc::free (temp as * mut c_void);
+ if temp != dirname {
+ libc::free(temp as *mut c_void);
}
+ return EXECUTION_FAILURE!();
}
-
- e =errno!();
- temp = printable_filename (dirname, 0);
- builtin_error (CString::new("%s: %s").unwrap().as_ptr(), temp, libc::strerror (e));
-
- if temp != dirname {
- libc::free (temp as * mut c_void);
- }
- return EXECUTION_FAILURE!();
- }
}
#[no_mangle]
-pub extern "C" fn r_pwd_builtin (list:* mut WordList)->i32 {
- let mut directory:* mut c_char;
- let mut opt:i32;
- let mut pflag:i32;
- unsafe {
- verbatim_pwd = no_symbolic_links;
- pflag = 0;
- reset_internal_getopt ();
- let c_str_lp = CString::new("LP").unwrap(); // from a &str, creates a new allocation
- opt = internal_getopt (list, c_str_lp.as_ptr() as * mut c_char);
- while opt != -1 {
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
- match optChar{
- 'P'=>{verbatim_pwd =1;
- pflag = 1;}
- 'L'=>{verbatim_pwd = 0;}
- _=>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
- }
- builtin_usage ();
- return EX_USAGE;
- }
- }
- opt = internal_getopt (list, c_str_lp.as_ptr() as * mut c_char);
- }
- if the_current_working_directory != std::ptr::null_mut() {
- if verbatim_pwd != 0 {
- directory=sh_physpath (the_current_working_directory, 0);
- } else {
- directory=the_current_working_directory;
- }
- } else {
- directory=get_working_directory(CString::new("pwd").unwrap().as_ptr() as * mut c_char);
- }
-
- /* Try again using getcwd() if canonicalization fails (for instance, if
- the file system has changed state underneath bash). */
- if (the_current_working_directory != std::ptr::null_mut() && directory == std::ptr::null_mut()) ||
- (posixly_correct !=0 && same_file (CString::new(".").unwrap().as_ptr(), the_current_working_directory, std::ptr::null_mut() , std::ptr::null_mut()) == 0) {
- if directory !=std::ptr::null_mut() && directory != the_current_working_directory {
- libc::free (directory as * mut c_void);
- }
- directory = r_resetpwd (CString::new("pwd").unwrap().as_ptr() as * mut c_char);
- }
+pub extern "C" fn r_pwd_builtin(list: *mut WordList) -> i32 {
+ let mut directory: *mut c_char;
+ let mut opt: i32;
+ let mut pflag: i32;
+ unsafe {
+ verbatim_pwd = no_symbolic_links;
+ pflag = 0;
+ reset_internal_getopt();
+ let c_str_lp = CString::new("LP").unwrap(); // from a &str, creates a new allocation
+ opt = internal_getopt(list, c_str_lp.as_ptr() as *mut c_char);
+ while opt != -1 {
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'P' => {
+ verbatim_pwd = 1;
+ pflag = 1;
+ }
+ 'L' => {
+ verbatim_pwd = 0;
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ opt = internal_getopt(list, c_str_lp.as_ptr() as *mut c_char);
+ }
+ if the_current_working_directory != std::ptr::null_mut() {
+ if verbatim_pwd != 0 {
+ directory = sh_physpath(the_current_working_directory, 0);
+ } else {
+ directory = the_current_working_directory;
+ }
+ } else {
+ directory = get_working_directory(CString::new("pwd").unwrap().as_ptr() as *mut c_char);
+ }
+
+ /* Try again using getcwd() if canonicalization fails (for instance, if
+ the file system has changed state underneath bash). */
+ if (the_current_working_directory != std::ptr::null_mut()
+ && directory == std::ptr::null_mut())
+ || (posixly_correct != 0
+ && same_file(
+ CString::new(".").unwrap().as_ptr(),
+ the_current_working_directory,
+ std::ptr::null_mut(),
+ std::ptr::null_mut(),
+ ) == 0)
+ {
+ if directory != std::ptr::null_mut() && directory != the_current_working_directory {
+ libc::free(directory as *mut c_void);
+ }
+ directory = r_resetpwd(CString::new("pwd").unwrap().as_ptr() as *mut c_char);
+ }
+
+ if directory != std::ptr::null_mut() {
+ opt = EXECUTION_SUCCESS!();
+ libc::printf(
+ CString::new("%s\n").unwrap().as_ptr() as *const c_char,
+ directory,
+ );
+ /* This is dumb but posix-mandated. */
+ if posixly_correct != 0 && pflag != 0 {
+ opt = r_setpwd(directory);
+ }
- if directory != std::ptr::null_mut() {
- opt = EXECUTION_SUCCESS!();
- libc::printf(CString::new("%s\n").unwrap().as_ptr() as * const c_char,directory);
- /* This is dumb but posix-mandated. */
- if posixly_correct !=0 && pflag !=0 {
- opt = r_setpwd (directory);
- }
-
- if directory != the_current_working_directory {
- libc::free (directory as * mut c_void);
- }
- return sh_chkwrite (opt);
- } else {
- return EXECUTION_FAILURE!();
- }
- }
+ if directory != the_current_working_directory {
+ libc::free(directory as *mut c_void);
+ }
+ return sh_chkwrite(opt);
+ } else {
+ return EXECUTION_FAILURE!();
+ }
+ }
}
/* Do the work of changing to the directory NEWDIR. Handle symbolic
- link following, etc. This function *must* return with
- the_current_working_directory either set to NULL (in which case
- getcwd() will eventually be called), or set to a string corresponding
- to the working directory. Return 1 on success, 0 on failure. */
+link following, etc. This function *must* return with
+the_current_working_directory either set to NULL (in which case
+getcwd() will eventually be called), or set to a string corresponding
+to the working directory. Return 1 on success, 0 on failure. */
#[no_mangle]
-pub extern "C" fn r_change_to_directory (newdir:* mut c_char, nolinks:i32, xattr:i32)->i32 {
- unsafe {
- let mut t:*mut c_char;
- let mut tdir:*mut c_char;
- let mut ndir:*mut c_char;
- let err:i32;
- let mut canon_failed:i32;
- let mut r:i32;
- let ndlen:i32;
-
- tdir = std::ptr::null_mut();
-
- if the_current_working_directory == std::ptr::null_mut() {
- t = get_working_directory (CString::new("chdir").unwrap().as_ptr() as * mut c_char);
- libc::free (t as * mut c_void);
- }
-
- t = make_absolute (newdir, the_current_working_directory);
-
- /* TDIR is either the canonicalized absolute pathname of NEWDIR
- (nolinks == 0) or the absolute physical pathname of NEWDIR
- (nolinks != 0). */
- if nolinks !=0 {
- tdir=sh_physpath (t, 0);
- } else {
- tdir=sh_canonpath (t, PATH_CHECKDOTDOT!()|PATH_CHECKEXISTS!());
- }
-
- ndlen = libc::strlen (newdir ) as i32;
-
- /* Use the canonicalized version of NEWDIR, or, if canonicalization
- failed, use the non-canonical form. */
- canon_failed = 0;
- if tdir !=std::ptr::null_mut() && *tdir !=0 {
- libc::free (t as * mut c_void);
- } else {
- libc::free (tdir as * mut c_void);
- tdir = t;
- canon_failed = 1;
- }
-
- /* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
- returns NULL (because it checks the path, it will return NULL if the
- resolved path doesn't exist), fail immediately. */
- if posixly_correct !=0 && nolinks == 0 && canon_failed !=0 && (errno!() != libc::ENAMETOOLONG || ndlen > libc::PATH_MAX) {
- if errno!() != libc::ENOENT && errno!() != libc::ENAMETOOLONG {
- errno!() = libc::ENOTDIR;
- }
- libc::free (tdir as * mut c_void);
- return 0;
- }
-
- {
- if nolinks !=0 {
- r = libc::chdir (newdir);
- } else {
- r = libc::chdir (tdir);
- }
+pub extern "C" fn r_change_to_directory(newdir: *mut c_char, nolinks: i32, xattr: i32) -> i32 {
+ unsafe {
+ let mut t: *mut c_char;
+ let mut tdir: *mut c_char;
+ let mut ndir: *mut c_char;
+ let err: i32;
+ let mut canon_failed: i32;
+ let mut r: i32;
+ let ndlen: i32;
+
+ tdir = std::ptr::null_mut();
+
+ if the_current_working_directory == std::ptr::null_mut() {
+ t = get_working_directory(CString::new("chdir").unwrap().as_ptr() as *mut c_char);
+ libc::free(t as *mut c_void);
+ }
- if r >= 0 {
- r_resetxattr ();
- }
+ t = make_absolute(newdir, the_current_working_directory);
+
+ /* TDIR is either the canonicalized absolute pathname of NEWDIR
+ (nolinks == 0) or the absolute physical pathname of NEWDIR
+ (nolinks != 0). */
+ if nolinks != 0 {
+ tdir = sh_physpath(t, 0);
+ } else {
+ tdir = sh_canonpath(t, PATH_CHECKDOTDOT!() | PATH_CHECKEXISTS!());
+ }
- }
+ ndlen = libc::strlen(newdir) as i32;
- /* If the chdir succeeds, update the_current_working_directory. */
- if r == 0 {
- /* If canonicalization failed, but the chdir succeeded, reset the
- shell's idea of the_current_working_directory. */
- if canon_failed !=0 {
- t = r_resetpwd (CString::new("cd").unwrap().as_ptr() as * mut c_char);
- if t == std::ptr::null_mut(){
- set_working_directory (tdir);
+ /* Use the canonicalized version of NEWDIR, or, if canonicalization
+ failed, use the non-canonical form. */
+ canon_failed = 0;
+ if tdir != std::ptr::null_mut() && *tdir != 0 {
+ libc::free(t as *mut c_void);
} else {
- libc::free (t as * mut c_void);
- }
- } else {
- set_working_directory (tdir);
- }
-
- libc::free (tdir as * mut c_void);
- return 1;
- }
-
- /* We failed to change to the appropriate directory name. If we tried
- what the user passed (nolinks != 0), punt now. */
- if nolinks !=0 {
- libc::free (tdir as * mut c_void);
- return 0;
- }
-
- err = errno!();
-
- /* We're not in physical mode (nolinks == 0), but we failed to change to
- the canonicalized directory name (TDIR). Try what the user passed
- verbatim. If we succeed, reinitialize the_current_working_directory.
- POSIX requires that we just fail here, so we do in posix mode. */
- if posixly_correct == 0 && libc::chdir (newdir) == 0 {
- t = r_resetpwd (CString::new("cd").unwrap().as_ptr() as * mut c_char);
- if t == std::ptr::null_mut() {
- set_working_directory (tdir);
- } else {
- libc::free (t as * mut c_void);
- }
- r = 1;
- } else {
- errno!()= err;
- r = 0;
- }
-
- libc::free (tdir as * mut c_void);
- return r;
- }
-}
+ libc::free(tdir as *mut c_void);
+ tdir = t;
+ canon_failed = 1;
+ }
+
+ /* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
+ returns NULL (because it checks the path, it will return NULL if the
+ resolved path doesn't exist), fail immediately. */
+ if posixly_correct != 0
+ && nolinks == 0
+ && canon_failed != 0
+ && (errno!() != libc::ENAMETOOLONG || ndlen > libc::PATH_MAX)
+ {
+ if errno!() != libc::ENOENT && errno!() != libc::ENAMETOOLONG {
+ errno!() = libc::ENOTDIR;
+ }
+ libc::free(tdir as *mut c_void);
+ return 0;
+ }
+
+ {
+ if nolinks != 0 {
+ r = libc::chdir(newdir);
+ } else {
+ r = libc::chdir(tdir);
+ }
+
+ if r >= 0 {
+ r_resetxattr();
+ }
+ }
+
+ /* If the chdir succeeds, update the_current_working_directory. */
+ if r == 0 {
+ /* If canonicalization failed, but the chdir succeeded, reset the
+ shell's idea of the_current_working_directory. */
+ if canon_failed != 0 {
+ t = r_resetpwd(CString::new("cd").unwrap().as_ptr() as *mut c_char);
+ if t == std::ptr::null_mut() {
+ set_working_directory(tdir);
+ } else {
+ libc::free(t as *mut c_void);
+ }
+ } else {
+ set_working_directory(tdir);
+ }
+
+ libc::free(tdir as *mut c_void);
+ return 1;
+ }
+
+ /* We failed to change to the appropriate directory name. If we tried
+ what the user passed (nolinks != 0), punt now. */
+ if nolinks != 0 {
+ libc::free(tdir as *mut c_void);
+ return 0;
+ }
+ err = errno!();
+
+ /* We're not in physical mode (nolinks == 0), but we failed to change to
+ the canonicalized directory name (TDIR). Try what the user passed
+ verbatim. If we succeed, reinitialize the_current_working_directory.
+ POSIX requires that we just fail here, so we do in posix mode. */
+ if posixly_correct == 0 && libc::chdir(newdir) == 0 {
+ t = r_resetpwd(CString::new("cd").unwrap().as_ptr() as *mut c_char);
+ if t == std::ptr::null_mut() {
+ set_working_directory(tdir);
+ } else {
+ libc::free(t as *mut c_void);
+ }
+ r = 1;
+ } else {
+ errno!() = err;
+ r = 0;
+ }
+
+ libc::free(tdir as *mut c_void);
+ return r;
+ }
+}
diff --git a/bash-5.1/builtins_rust/cmd/src/lib.rs b/bash-5.1/builtins_rust/cmd/src/lib.rs
index bce494c4425883bd9877fc73b27f4b85ee876794..161713c6a955d7f77fe15ac77a02d8e1f9fe9291 100644
--- a/bash-5.1/builtins_rust/cmd/src/lib.rs
+++ b/bash-5.1/builtins_rust/cmd/src/lib.rs
@@ -1,4 +1,4 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
use std::collections::HashMap;
@@ -7,45 +7,41 @@ use std::sync::Mutex;
extern crate lazy_static;
pub struct Cmd {
- name:String,
- enable:bool,
+ name: String,
+ enable: bool,
}
impl Cmd {
-pub fn build_cmd(name:String, enable:bool) -> Cmd {
- Cmd {
- name,
- enable,
+ pub fn build_cmd(name: String, enable: bool) -> Cmd {
+ Cmd { name, enable }
}
-}
-pub fn set_enable(&mut self, is_enable:bool) -> &Cmd {
- self.enable = is_enable;
- self
-}
-pub fn get_enable(&self) -> bool {
- return self.enable
-}
+ pub fn set_enable(&mut self, is_enable: bool) -> &Cmd {
+ self.enable = is_enable;
+ self
+ }
+ pub fn get_enable(&self) -> bool {
+ return self.enable;
+ }
}
lazy_static! {
-static ref CMD: Mutex>> = Mutex::new(HashMap::new());
-}
-fn init_cmd_table() {
+ static ref CMD: Mutex>> = Mutex::new(HashMap::new());
}
+fn init_cmd_table() {}
-pub fn insert_empty_cmd(cmd:String) -> bool {
- let it = Cmd::build_cmd(String::from(&cmd[..]),true);
+pub fn insert_empty_cmd(cmd: String) -> bool {
+ let it = Cmd::build_cmd(String::from(&cmd[..]), true);
let mut cmd_table = CMD.lock().unwrap();
cmd_table.insert(String::from(&cmd[..]), Box::new(it));
return true;
}
-pub fn insert_cmd(cmd:&str, item: Box) -> Option>{
+pub fn insert_cmd(cmd: &str, item: Box) -> Option> {
let mut cmd_table = CMD.lock().unwrap();
cmd_table.insert(String::from(cmd), item)
}
-pub fn get_cmd_enable(cmd:String) -> Result{
- let mut cmd_table = CMD.lock().unwrap();
+pub fn get_cmd_enable(cmd: String) -> Result {
+ let cmd_table = CMD.lock().unwrap();
let item = cmd_table.get(&cmd);
match item {
Some(c) => {
@@ -54,12 +50,12 @@ pub fn get_cmd_enable(cmd:String) -> Result{
return Ok(c.enable);
}
None => {
- return Err(cmd+" not found");
+ return Err(cmd + " not found");
}
}
}
-pub fn set_cmd_enable(cmd :String, is_enable:bool)->bool {
+pub fn set_cmd_enable(cmd: String, is_enable: bool) -> bool {
let mut a = CMD.lock().unwrap();
let v = a.get_mut(&cmd);
match v {
diff --git a/bash-5.1/builtins_rust/colon/src/lib.rs b/bash-5.1/builtins_rust/colon/src/lib.rs
index 24e70d3054a64346beed5052bb29c0c513618895..f13a0717aa3f6864f9c8ad5e2d52fb5a051c6015 100644
--- a/bash-5.1/builtins_rust/colon/src/lib.rs
+++ b/bash-5.1/builtins_rust/colon/src/lib.rs
@@ -1,9 +1,8 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use std::{ffi::CString};
-use libc::{size_t, c_int, c_uint, c_char, c_long, c_void, PT_NULL, c_ulong, strchr};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+
+use rcommon::WordList;
#[cfg(test)]
mod tests {
@@ -14,13 +13,12 @@ mod tests {
}
}
-
#[no_mangle]
-pub extern "C" fn r_colon_builtin(ignore: *mut WordList )->i32 {
+pub extern "C" fn r_colon_builtin(_ignore: *mut WordList) -> i32 {
0
}
#[no_mangle]
-pub extern "C" fn r_false_builtin(ignore: *mut WordList) -> i32 {
+pub extern "C" fn r_false_builtin(_ignore: *mut WordList) -> i32 {
1
}
diff --git a/bash-5.1/builtins_rust/command/src/lib.rs b/bash-5.1/builtins_rust/command/src/lib.rs
index c44e1a556d94fccd0ae3d6ee7ff8087faec3fe15..cde2d37774e09c294256f28261eb57c6cb0d4dff 100644
--- a/bash-5.1/builtins_rust/command/src/lib.rs
+++ b/bash-5.1/builtins_rust/command/src/lib.rs
@@ -1,9 +1,9 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
use std::ffi::*;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
extern "C" {
fn copy_word_list(_: *mut WordList) -> *mut WordList;
@@ -229,13 +229,13 @@ pub struct for_com {
pub action: *mut COMMAND,
}
-pub const CDESC_ALL:i32 = 0x001;
+pub const CDESC_ALL: i32 = 0x001;
pub const CDESC_SHORTDESC: i32 = 0x002;
-pub const CDESC_REUSABLE:i32 = 0x004;
+pub const CDESC_REUSABLE: i32 = 0x004;
pub const CDESC_TYPE: i32 = 0x008;
-pub const CDESC_PATH_ONLY:i32 = 0x010;
+pub const CDESC_PATH_ONLY: i32 = 0x010;
pub const CDESC_FORCE_PATH: i32 = 0x020;
-pub const CDESC_NOFUNCS:i32 = 0x040;
+pub const CDESC_NOFUNCS: i32 = 0x040;
pub const CDESC_ABSPATH: i32 = 0x080;
pub const CDESC_STDPATH: i32 = 0x100;
@@ -248,43 +248,41 @@ pub const CDESC_STDPATH: i32 = 0x100;
//#define CDESC_NOFUNCS 0x040 /* type -f */
//#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */
//#define CDESC_STDPATH 0x100 /* command -p */
-
-
-pub const const_command_builtin:*mut libc::c_char = b"command_builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char;//.unwrap();
-//#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0))
-//#define CMD_WANT_SUBSHELL 0x01 /* User wants a subshell: ( command ) */
-//#define CMD_FORCE_SUBSHELL 0x02 /* Shell needs to force a subshell. */
-//#define CMD_INVERT_RETURN 0x04 /* Invert the exit value. */
-//#define CMD_IGNORE_RETURN 0x08 /* Ignore the exit value. For set -e. */
-//#define CMD_NO_FUNCTIONS 0x10 /* Ignore functions during command lookup. */
-//#define CMD_INHIBIT_EXPANSION 0x20 /* Do not expand the command words. */
-//#define CMD_NO_FORK 0x40 /* Don't fork; just call execve */
-//#define CMD_TIME_PIPELINE 0x80 /* Time a pipeline */
-//#define CMD_TIME_POSIX 0x100 /* time -p; use POSIX.2 time output spec. */
-//#define CMD_AMPERSAND 0x200 /* command & */
-//#define CMD_STDIN_REDIR 0x400 /* async command needs implicit libc::c_int {
@@ -299,7 +297,7 @@ pub unsafe extern "C" fn r_command_builtin(mut list: *mut WordList) -> libc::c_i
reset_internal_getopt();
let adnpsf = CString::new("pvV").expect("CString::new failed");
loop {
- opt = internal_getopt(list, adnpsf.as_ptr() );
+ opt = internal_getopt(list, adnpsf.as_ptr());
if !(opt != -1) {
break;
}
@@ -315,7 +313,7 @@ pub unsafe extern "C" fn r_command_builtin(mut list: *mut WordList) -> libc::c_i
verbose = CDESC_REUSABLE; // ditto
}
_ => {
- if opt ==-99 {
+ if opt == -99 {
r_builtin_help();
return EX_USAGE;
}
@@ -345,28 +343,32 @@ pub unsafe extern "C" fn r_command_builtin(mut list: *mut WordList) -> libc::c_i
any_found += found;
list = (*list).next;
}
- return if any_found != 0 { EXECUTION_SUCCESS!() } else { EXECUTION_FAILURE!() };
+ return if any_found != 0 {
+ EXECUTION_SUCCESS!()
+ } else {
+ EXECUTION_FAILURE!()
+ };
}
- begin_unwind_frame(
- const_command_builtin
- );
+ begin_unwind_frame(const_command_builtin);
command = make_bare_simple_command();
// let ref mut fresh0 = (*(*command).value.Simple).words;
//*fresh0 = copy_word_list(list);
(*(*command).value.Simple).words = copy_word_list(list);
//let ref mut fresh1 = (*(*command).value.Simple).redirects;
//*fresh1 = 0 as *mut libc::c_void as *mut REDIRECT;
- (*(*command).value.Simple).redirects = 0 as *mut libc::c_void as *mut REDIRECT;
+ (*(*command).value.Simple).redirects = 0 as *mut libc::c_void as *mut REDIRECT;
- (*command).flags
- |= CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN
- | (if use_standard_path != 0 {
- CMD_STDPATH
- } else {
- 0 as libc::c_int
- });
- (*(*command).value.Simple).flags
- |= CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN
+ (*command).flags |= CMD_NO_FUNCTIONS
+ | CMD_INHIBIT_EXPANSION
+ | CMD_COMMAND_BUILTIN
+ | (if use_standard_path != 0 {
+ CMD_STDPATH
+ } else {
+ 0 as libc::c_int
+ });
+ (*(*command).value.Simple).flags |= CMD_NO_FUNCTIONS
+ | CMD_INHIBIT_EXPANSION
+ | CMD_COMMAND_BUILTIN
| (if use_standard_path != 0 {
CMD_STDPATH
} else {
@@ -380,8 +382,6 @@ pub unsafe extern "C" fn r_command_builtin(mut list: *mut WordList) -> libc::c_i
command,
);*/
result = execute_command(command);
- run_unwind_frame(
- b"command_builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- );
+ run_unwind_frame(b"command_builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char);
return result;
}
diff --git a/bash-5.1/builtins_rust/common/src/lib.rs b/bash-5.1/builtins_rust/common/src/lib.rs
index b7b39842e3ec8ccc972c410ac7c50078b2e08c41..9d6900c5bee64ff3fcecb578798ea7e4d2f92eda 100644
--- a/bash-5.1/builtins_rust/common/src/lib.rs
+++ b/bash-5.1/builtins_rust/common/src/lib.rs
@@ -3,19 +3,22 @@
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
-use libc::{c_char,c_int, c_void, FILE, size_t, intmax_t,c_long, strcmp};
-use libc::{isdigit,strerror, __errno_location, fflush, ferror,clearerr, free,strcpy,strlen,strncmp,atoi,qsort};
+use libc::{
+ __errno_location, atoi, clearerr, ferror, fflush, free, isdigit, qsort, strerror, strlen,
+ strncmp,
+};
+use libc::{c_char, c_int, c_long, c_void, intmax_t, size_t, strcmp, FILE};
+use nix::errno::errno;
+use std::env::var;
use std::ffi::{CStr, CString};
use std::mem::size_of;
use std::ptr::read_volatile;
-use nix::errno::errno;
-use std::env::var;
use unic_langid::LanguageIdentifier;
include!(concat!("lib_readline_keymaps.rs"));
include!(concat!("command.rs"));
-use fluent_bundle::{FluentBundle, FluentResource, FluentValue, FluentArgs};
+use fluent_bundle::FluentArgs;
use fluent_resmgr::resource_manager::ResourceManager;
//struct
@@ -35,29 +38,29 @@ pub struct word_list {
}
pub type WordList = word_list;
-#[repr (C)]
-pub struct builtin{
- pub name:*mut c_char,
- pub function:*mut sh_builtin_func_t,
- pub flags:i32,
- pub long_doc: *const *mut c_char ,
- pub short_doc:*const c_char,
- pub handle:*mut c_char,
+#[repr(C)]
+pub struct builtin {
+ pub name: *mut c_char,
+ pub function: *mut sh_builtin_func_t,
+ pub flags: i32,
+ pub long_doc: *const *mut c_char,
+ pub short_doc: *const c_char,
+ pub handle: *mut c_char,
}
-#[repr (C)]
-pub struct g_list{
- pub next:*mut g_list,
+#[repr(C)]
+pub struct g_list {
+ pub next: *mut g_list,
}
type GENERIC_LIST = g_list;
-#[repr (C)]
-pub struct process{
- pub next:*mut process,
- pub pid:pid_t,
- pub status:WAIT,
- pub running:i32,
- pub command:*mut c_char,
+#[repr(C)]
+pub struct process {
+ pub next: *mut process,
+ pub pid: pid_t,
+ pub status: WAIT,
+ pub running: i32,
+ pub command: *mut c_char,
}
type WAIT = i32;
type pid_t = c_int;
@@ -242,7 +245,6 @@ pub union VALUE_COMMAND {
Coproc:*mut coproc_com
}
-
#[repr(u8)]
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
cm_connection, cm_function_def, cm_until, cm_group,
@@ -517,12 +519,10 @@ macro_rules! non_unsettable_p {
#[macro_export]
macro_rules! VUNSETATTR {
($var:expr,$attr:expr) => {
- (*$var).attributes &= !($attr)
+ (*$var).attributes &= ($attr)
};
}
-
-
#[macro_export]
macro_rules! ISOCTAL {
($c:expr) => {
@@ -564,11 +564,10 @@ macro_rules! STREQN {
($a:expr,$b:expr,$n:expr) => {
if $n == 0 {
1
+ } else {
+ (*$a == *$b && strncmp($a, $b, $n) == 0) as i32
}
- else{
- (*$a == *$b && strncmp($a,$b,$n) == 0) as i32
- }
- }
+ };
}
#[macro_export]
@@ -1428,7 +1427,7 @@ pub extern "C" fn r_get_job_spec(list:*mut WordList)->i32{
* NOTE: `kill' calls this function with forcecols == 0
*/
pub extern "C" fn r_display_signal_list(mut list:*mut WordList,forcecols:i32)->i32{
- let mut i:i32;
+ let mut _i:i32;
let mut column:i32;
let mut name:*mut c_char;
let mut result:i32;
@@ -1546,10 +1545,10 @@ pub extern "C" fn r_display_signal_list(mut list:*mut WordList,forcecols:i32)->i
DISABLED_OKAY means find it even if the builtin is disabled. */
extern "C" fn r_print_builtin_name() {
- let mut hi:i32;
- let mut lo:i32;
- let mut mid:i32 = 0;
- let mut j:i32;
+ let hi:i32;
+ let lo:i32;
+ let _mid:i32 = 0;
+ let mut _j:i32;
unsafe{
hi = num_shell_builtins -1;
@@ -1790,15 +1789,15 @@ pub unsafe fn err_translate_fn (command:&String , args1 : *mut libc::c_char) {
}
let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message(command).unwrap();
- let mut pattern = value.value().expect("partern err");
+ let value = bundle.get_message(command).unwrap();
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
if args1 != std::ptr::null_mut(){
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
eprint!("{msg1}");
}
else {
- let mut msg1 = bundle.format_pattern(&pattern, None, &mut errors);
+ let msg1 = bundle.format_pattern(&pattern, None, &mut errors);
eprint!("{msg1}");
}
}
@@ -1812,15 +1811,15 @@ pub unsafe fn translate_fn (command:&String , args1 : *mut libc::c_char) {
}
let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message(command).unwrap();
- let mut pattern = value.value().expect("partern err");
+ let value = bundle.get_message(command).unwrap();
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
if args1 != std::ptr::null_mut(){
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
print!("{msg1}");
}
else {
- let mut msg1 = bundle.format_pattern(&pattern, None, &mut errors);
+ let msg1 = bundle.format_pattern(&pattern, None, &mut errors);
print!("{msg1}");
}
-}
\ No newline at end of file
+}
diff --git a/bash-5.1/builtins_rust/complete/src/lib.rs b/bash-5.1/builtins_rust/complete/src/lib.rs
index 74a8d9e1f8be1712a83eba5c1ff44b30192a185d..248859b6b19c5dcfe022f5e72ca65ac4185144df 100644
--- a/bash-5.1/builtins_rust/complete/src/lib.rs
+++ b/bash-5.1/builtins_rust/complete/src/lib.rs
@@ -1,1383 +1,1605 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
use libc::{c_char, c_int, c_ulong, c_void};
-use std::{ffi::CString, ffi::CStr};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, r_savestring} ;
+use rcommon::{r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
+use std::{ffi::CStr, ffi::CString};
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub union REDIRECTEE {
- dest:c_int,
- filename:* mut WordDesc
+ dest: c_int,
+ filename: *mut WordDesc,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:REDIRECTEE,
- rflags:c_int,
- flags:c_int,
- instruction:r_instruction,
- redirectee:REDIRECTEE,
- here_doc_eof:*mut c_char
+ next: *mut REDIRECT,
+ redirector: REDIRECTEE,
+ rflags: c_int,
+ flags: c_int,
+ instruction: r_instruction,
+ redirectee: REDIRECTEE,
+ here_doc_eof: *mut c_char,
}
/* FOR command. */
#[repr(C)]
pub struct for_com {
- flags:c_int,
- line:c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: c_int,
+ line: c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:c_int
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: c_int,
}
#[repr(C)]
pub struct case_com {
- flags:c_int,
- line:c_int,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ flags: c_int,
+ line: c_int,
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct while_com {
- flags:c_int,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: c_int,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
- flags:c_int,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ flags: c_int,
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore:c_int,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector:c_int
+ ignore: c_int,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: c_int,
}
#[repr(C)]
pub struct simple_com {
- flags:c_int,
- line:c_int,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: c_int,
+ line: c_int,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags:c_int,
- line:c_int,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut c_char
+ flags: c_int,
+ line: c_int,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct group_com {
- ignore:libc::c_int,
- command:*mut COMMAND,
- source_file:*mut c_char
+ ignore: libc::c_int,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct select_com {
- flags:c_int,
- line:c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: c_int,
+ line: c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct arith_com {
- flags:c_int,
- line:c_int,
- exp:*mut WordList
+ flags: c_int,
+ line: c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct cond_com {
- flags:c_int,
- line:c_int,
- type_c:c_int,
- exp:*mut WordList
+ flags: c_int,
+ line: c_int,
+ type_c: c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct arith_for_com {
- flags:c_int,
- line:c_int,
- init:*mut WordList,
- test:*mut WordList,
- step:*mut WordList,
- action:*mut COMMAND
+ flags: c_int,
+ line: c_int,
+ init: *mut WordList,
+ test: *mut WordList,
+ step: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct subshell_com {
- flags:i32,
- line:i32,
- command:*mut COMMAND
+ flags: i32,
+ line: i32,
+ command: *mut COMMAND,
}
#[repr(C)]
pub struct coproc_com {
- flags:i32,
- name:*mut c_char,
- command:*mut COMMAND
+ flags: i32,
+ name: *mut c_char,
+ command: *mut COMMAND,
}
#[repr(C)]
pub union VALUE_COMMAND {
- For:*mut for_com,
- Case:*mut case_com,
- While:*mut while_com,
- If:*mut if_com,
- Connection:*mut connection,
- Simple:*mut simple_com,
- Function_def:*mut function_def,
- Group:*mut group_com,
- Select:*mut select_com,
- Arith:*mut arith_com,
- Cond:*mut cond_com,
- ArithFor:*mut arith_for_com,
- Subshell:*mut subshell_com,
- Coproc:*mut coproc_com
+ For: *mut for_com,
+ Case: *mut case_com,
+ While: *mut while_com,
+ If: *mut if_com,
+ Connection: *mut connection,
+ Simple: *mut simple_com,
+ Function_def: *mut function_def,
+ Group: *mut group_com,
+ Select: *mut select_com,
+ Arith: *mut arith_com,
+ Cond: *mut cond_com,
+ ArithFor: *mut arith_for_com,
+ Subshell: *mut subshell_com,
+ Coproc: *mut coproc_com,
}
#[repr(C)]
pub struct COMMAND {
- type_c:command_type,
- flags:i32,
- line:i32,
- redirects:*mut REDIRECT,
- value:VALUE_COMMAND
+ type_c: command_type,
+ flags: i32,
+ line: i32,
+ redirects: *mut REDIRECT,
+ value: VALUE_COMMAND,
}
/* Structure containing all the non-action (binary) options; filled in by
- build_actions(). */
+build_actions(). */
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub struct _optflags {
- pflag:c_int,
- rflag:c_int,
- Dflag:c_int,
- Eflag:c_int,
- Iflag:c_int
+ pflag: c_int,
+ rflag: c_int,
+ Dflag: c_int,
+ Eflag: c_int,
+ Iflag: c_int,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub struct _compacts {
- actname:* const c_char,
- actflag:libc::c_ulong,
- actopt:c_int,
+ actname: *const c_char,
+ actflag: libc::c_ulong,
+ actopt: c_int,
}
pub struct CompactsArray {
- compactsArr:[_compacts;25usize]
+ compactsArr: [_compacts; 25usize],
}
impl CompactsArray {
- pub fn new()->CompactsArray {
- CompactsArray{
- compactsArr:[
- _compacts{ actname:b"alias\0".as_ptr() as *const c_char, actflag: CA_ALIAS!(),actopt: 'a' as c_int },
- _compacts{ actname:b"arrayvar\0".as_ptr() as *const c_char, actflag: CA_ARRAYVAR!(),actopt: 0 as c_int },
- _compacts{ actname:b"binding\0".as_ptr() as *const c_char, actflag: CA_BINDING!(),actopt: 0 as c_int },
- _compacts{ actname:b"builtin\0".as_ptr() as *const c_char, actflag: CA_BUILTIN!(),actopt: 'b' as c_int },
- _compacts{ actname:b"command\0".as_ptr() as *const c_char, actflag: CA_COMMAND!(),actopt: 'c' as c_int },
- _compacts{ actname:b"directory\0".as_ptr() as *const c_char, actflag: CA_DIRECTORY!(),actopt: 'd' as c_int },
- _compacts{ actname:b"disabled\0".as_ptr() as *const c_char, actflag: CA_DISABLED!(),actopt: 0 as c_int },
- _compacts{ actname:b"enabled\0".as_ptr() as *const c_char, actflag: CA_ENABLED!(),actopt: 0 as c_int },
- _compacts{ actname:b"export\0".as_ptr() as *const c_char, actflag: CA_EXPORT!(),actopt: 'e' as c_int },
- _compacts{ actname:b"file\0".as_ptr() as *const c_char, actflag: CA_FILE!(),actopt: 'f' as c_int },
- _compacts{ actname:b"function\0".as_ptr() as *const c_char, actflag: CA_FUNCTION!(),actopt: 0 as c_int },
- _compacts{ actname:b"helptopic\0".as_ptr() as *const c_char, actflag: CA_HELPTOPIC!(),actopt: 0 as c_int },
- _compacts{ actname:b"hostname\0".as_ptr() as *const c_char, actflag: CA_HOSTNAME!(),actopt: 0 as c_int },
- _compacts{ actname:b"group\0".as_ptr() as *const c_char, actflag: CA_GROUP!(),actopt: 'g' as c_int },
- _compacts{ actname:b"job\0".as_ptr() as *const c_char, actflag: CA_JOB!(),actopt: 'j' as c_int },
- _compacts{ actname:b"keyword\0".as_ptr() as *const c_char, actflag: CA_KEYWORD!(),actopt: 'k' as c_int },
- _compacts{ actname:b"running\0".as_ptr() as *const c_char, actflag: CA_RUNNING!(),actopt: 0 as c_int },
- _compacts{ actname:b"service\0".as_ptr() as *const c_char, actflag: CA_SERVICE!(),actopt: 's' as c_int },
- _compacts{ actname:b"setopt\0".as_ptr() as *const c_char, actflag: CA_SETOPT!(),actopt: 0 as c_int },
- _compacts{ actname:b"shopt\0".as_ptr() as *const c_char, actflag: CA_SHOPT!(),actopt: 0 as c_int },
- _compacts{ actname:b"signal\0".as_ptr() as *const c_char, actflag: CA_SIGNAL!(),actopt: 0 as c_int },
- _compacts{ actname:b"stopped\0".as_ptr() as *const c_char, actflag: CA_STOPPED!(),actopt: 0 as c_int },
- _compacts{ actname:b"user\0".as_ptr() as *const c_char, actflag: CA_USER!(),actopt: 'u' as c_int },
- _compacts{ actname:b"variable\0".as_ptr() as *const c_char, actflag: CA_VARIABLE!(),actopt: 'v' as c_int },
- _compacts{ actname:std::ptr::null_mut(), actflag: 0,actopt: 0 as c_int },
- ]
- }
+ pub fn new() -> CompactsArray {
+ CompactsArray {
+ compactsArr: [
+ _compacts {
+ actname: b"alias\0".as_ptr() as *const c_char,
+ actflag: CA_ALIAS!(),
+ actopt: 'a' as c_int,
+ },
+ _compacts {
+ actname: b"arrayvar\0".as_ptr() as *const c_char,
+ actflag: CA_ARRAYVAR!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"binding\0".as_ptr() as *const c_char,
+ actflag: CA_BINDING!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"builtin\0".as_ptr() as *const c_char,
+ actflag: CA_BUILTIN!(),
+ actopt: 'b' as c_int,
+ },
+ _compacts {
+ actname: b"command\0".as_ptr() as *const c_char,
+ actflag: CA_COMMAND!(),
+ actopt: 'c' as c_int,
+ },
+ _compacts {
+ actname: b"directory\0".as_ptr() as *const c_char,
+ actflag: CA_DIRECTORY!(),
+ actopt: 'd' as c_int,
+ },
+ _compacts {
+ actname: b"disabled\0".as_ptr() as *const c_char,
+ actflag: CA_DISABLED!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"enabled\0".as_ptr() as *const c_char,
+ actflag: CA_ENABLED!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"export\0".as_ptr() as *const c_char,
+ actflag: CA_EXPORT!(),
+ actopt: 'e' as c_int,
+ },
+ _compacts {
+ actname: b"file\0".as_ptr() as *const c_char,
+ actflag: CA_FILE!(),
+ actopt: 'f' as c_int,
+ },
+ _compacts {
+ actname: b"function\0".as_ptr() as *const c_char,
+ actflag: CA_FUNCTION!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"helptopic\0".as_ptr() as *const c_char,
+ actflag: CA_HELPTOPIC!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"hostname\0".as_ptr() as *const c_char,
+ actflag: CA_HOSTNAME!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"group\0".as_ptr() as *const c_char,
+ actflag: CA_GROUP!(),
+ actopt: 'g' as c_int,
+ },
+ _compacts {
+ actname: b"job\0".as_ptr() as *const c_char,
+ actflag: CA_JOB!(),
+ actopt: 'j' as c_int,
+ },
+ _compacts {
+ actname: b"keyword\0".as_ptr() as *const c_char,
+ actflag: CA_KEYWORD!(),
+ actopt: 'k' as c_int,
+ },
+ _compacts {
+ actname: b"running\0".as_ptr() as *const c_char,
+ actflag: CA_RUNNING!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"service\0".as_ptr() as *const c_char,
+ actflag: CA_SERVICE!(),
+ actopt: 's' as c_int,
+ },
+ _compacts {
+ actname: b"setopt\0".as_ptr() as *const c_char,
+ actflag: CA_SETOPT!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"shopt\0".as_ptr() as *const c_char,
+ actflag: CA_SHOPT!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"signal\0".as_ptr() as *const c_char,
+ actflag: CA_SIGNAL!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"stopped\0".as_ptr() as *const c_char,
+ actflag: CA_STOPPED!(),
+ actopt: 0 as c_int,
+ },
+ _compacts {
+ actname: b"user\0".as_ptr() as *const c_char,
+ actflag: CA_USER!(),
+ actopt: 'u' as c_int,
+ },
+ _compacts {
+ actname: b"variable\0".as_ptr() as *const c_char,
+ actflag: CA_VARIABLE!(),
+ actopt: 'v' as c_int,
+ },
+ _compacts {
+ actname: std::ptr::null_mut(),
+ actflag: 0,
+ actopt: 0 as c_int,
+ },
+ ],
+ }
}
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub struct _compopt {
- optname:* const c_char,
- optflag:libc::c_ulong,
+ optname: *const c_char,
+ optflag: libc::c_ulong,
}
pub struct CompoptArray {
- compoptArr:[_compopt;9usize]
+ compoptArr: [_compopt; 9usize],
}
impl CompoptArray {
- pub fn new()->CompoptArray{
- CompoptArray{
- compoptArr:[
- _compopt{ optname:"bashdefault\0".as_ptr() as *const c_char, optflag:COPT_BASHDEFAULT!() },
- _compopt{ optname:"default\0".as_ptr() as *const c_char, optflag:COPT_DEFAULT!() },
- _compopt{ optname:"dirnames\0".as_ptr() as *const c_char, optflag:COPT_DIRNAMES!() },
- _compopt{ optname:"filenames\0".as_ptr() as *const c_char,optflag:COPT_FILENAMES!()},
- _compopt{ optname:"noquote\0".as_ptr() as *const c_char, optflag:COPT_NOQUOTE!() },
- _compopt{ optname:"nosort\0".as_ptr() as *const c_char, optflag:COPT_NOSORT!() },
- _compopt{ optname:"nospace\0".as_ptr() as *const c_char, optflag:COPT_NOSPACE!() },
- _compopt{ optname:"plusdirs\0".as_ptr() as *const c_char, optflag:COPT_PLUSDIRS!() },
- _compopt{ optname:std::ptr::null_mut(), optflag:0 },
- ]
+ pub fn new() -> CompoptArray {
+ CompoptArray {
+ compoptArr: [
+ _compopt {
+ optname: "bashdefault\0".as_ptr() as *const c_char,
+ optflag: COPT_BASHDEFAULT!(),
+ },
+ _compopt {
+ optname: "default\0".as_ptr() as *const c_char,
+ optflag: COPT_DEFAULT!(),
+ },
+ _compopt {
+ optname: "dirnames\0".as_ptr() as *const c_char,
+ optflag: COPT_DIRNAMES!(),
+ },
+ _compopt {
+ optname: "filenames\0".as_ptr() as *const c_char,
+ optflag: COPT_FILENAMES!(),
+ },
+ _compopt {
+ optname: "noquote\0".as_ptr() as *const c_char,
+ optflag: COPT_NOQUOTE!(),
+ },
+ _compopt {
+ optname: "nosort\0".as_ptr() as *const c_char,
+ optflag: COPT_NOSORT!(),
+ },
+ _compopt {
+ optname: "nospace\0".as_ptr() as *const c_char,
+ optflag: COPT_NOSPACE!(),
+ },
+ _compopt {
+ optname: "plusdirs\0".as_ptr() as *const c_char,
+ optflag: COPT_PLUSDIRS!(),
+ },
+ _compopt {
+ optname: std::ptr::null_mut(),
+ optflag: 0,
+ },
+ ],
+ }
}
- }
}
#[repr(C)]
pub struct COMPSPEC {
- refcount:c_int,
- actions:c_ulong,
- options:c_ulong,
- globpat:* mut c_char,
- words:* mut c_char,
- prefix: * mut c_char,
- suffix: * mut c_char,
- funcname: * mut c_char,
- command:* mut c_char,
- lcommand:* mut c_char,
- filterpat:* mut c_char,
+ refcount: c_int,
+ actions: c_ulong,
+ options: c_ulong,
+ globpat: *mut c_char,
+ words: *mut c_char,
+ prefix: *mut c_char,
+ suffix: *mut c_char,
+ funcname: *mut c_char,
+ command: *mut c_char,
+ lcommand: *mut c_char,
+ filterpat: *mut c_char,
}
#[repr(C)]
pub struct BUCKET_CONTENTS {
- next:* mut BUCKET_CONTENTS, /* Link to next hashed key in this bucket. */
- key:* mut c_char, /* What we look up. */
- data:* mut libc::c_void, /* What we really want. */
- khash:libc::c_uint, /* What key hashes to */
- times_found:i32, /* Number of times this item has been found. */
+ next: *mut BUCKET_CONTENTS, /* Link to next hashed key in this bucket. */
+ key: *mut c_char, /* What we look up. */
+ data: *mut libc::c_void, /* What we really want. */
+ khash: libc::c_uint, /* What key hashes to */
+ times_found: i32, /* Number of times this item has been found. */
}
#[repr(C)]
pub struct STRINGLIST {
- list:* mut * mut c_char,
- list_size:c_int,
- list_len:c_int,
+ list: *mut *mut c_char,
+ list_size: c_int,
+ list_len: c_int,
}
-
#[macro_export]
macro_rules! CA_ALIAS {
- () => {
- 1<<0
- }
+ () => {
+ 1 << 0
+ };
}
#[macro_export]
macro_rules! CA_ARRAYVAR {
- () => {
- 1<<1
- }
+ () => {
+ 1 << 1
+ };
}
#[macro_export]
macro_rules! CA_BINDING {
- () => {
- 1<<2
- }
+ () => {
+ 1 << 2
+ };
}
#[macro_export]
macro_rules! CA_BUILTIN {
- () => {
- 1<<3
- }
+ () => {
+ 1 << 3
+ };
}
#[macro_export]
macro_rules! CA_COMMAND {
- () => {
- 1<<4
- }
+ () => {
+ 1 << 4
+ };
}
#[macro_export]
macro_rules! CA_DIRECTORY {
- () => {
- 1<<5
- }
+ () => {
+ 1 << 5
+ };
}
#[macro_export]
macro_rules! CA_DISABLED {
- () => {
- 1<<6
- }
+ () => {
+ 1 << 6
+ };
}
#[macro_export]
macro_rules! CA_ENABLED {
- () => {
- 1<<7
- }
+ () => {
+ 1 << 7
+ };
}
#[macro_export]
macro_rules! CA_EXPORT {
- () => {
- 1<<8
- }
+ () => {
+ 1 << 8
+ };
}
#[macro_export]
macro_rules! CA_FILE {
- () => {
- 1<<9
- }
+ () => {
+ 1 << 9
+ };
}
#[macro_export]
macro_rules! CA_FUNCTION {
- () => {
- 1<<10
- }
+ () => {
+ 1 << 10
+ };
}
#[macro_export]
macro_rules! CA_GROUP {
- () => {
- 1<<11
- }
+ () => {
+ 1 << 11
+ };
}
#[macro_export]
macro_rules! CA_HELPTOPIC {
- () => {
- 1<<12
- }
+ () => {
+ 1 << 12
+ };
}
#[macro_export]
macro_rules! CA_HOSTNAME {
- () => {
- 1<<13
- }
+ () => {
+ 1 << 13
+ };
}
#[macro_export]
macro_rules! CA_JOB {
- () => {
- 1<<14
- }
+ () => {
+ 1 << 14
+ };
}
#[macro_export]
macro_rules! CA_KEYWORD {
- () => {
- 1<<15
- }
+ () => {
+ 1 << 15
+ };
}
#[macro_export]
macro_rules! CA_RUNNING {
- () => {
- 1<<16
- }
+ () => {
+ 1 << 16
+ };
}
#[macro_export]
macro_rules! CA_SERVICE {
- () => {
- 1<<17
- }
+ () => {
+ 1 << 17
+ };
}
#[macro_export]
macro_rules! CA_SETOPT {
- () => {
- 1<<18
- }
+ () => {
+ 1 << 18
+ };
}
#[macro_export]
macro_rules! CA_SHOPT {
- () => {
- 1<<19
- }
+ () => {
+ 1 << 19
+ };
}
#[macro_export]
macro_rules! CA_SIGNAL {
- () => {
- 1<<20
- }
+ () => {
+ 1 << 20
+ };
}
#[macro_export]
macro_rules! CA_STOPPED {
- () => {
- 1<<21
- }
+ () => {
+ 1 << 21
+ };
}
#[macro_export]
macro_rules! CA_USER {
- () => {
- 1<<22
- }
+ () => {
+ 1 << 22
+ };
}
#[macro_export]
macro_rules! CA_VARIABLE {
- () => {
- 1<<23
- }
+ () => {
+ 1 << 23
+ };
}
#[macro_export]
macro_rules! COPT_RESERVED {
- () => {
- 1<<0
- }
+ () => {
+ 1 << 0
+ };
}
#[macro_export]
macro_rules! COPT_DEFAULT {
- () => {
- 1<<1
- }
+ () => {
+ 1 << 1
+ };
}
#[macro_export]
macro_rules! COPT_FILENAMES {
- () => {
- 1<<2
- }
+ () => {
+ 1 << 2
+ };
}
#[macro_export]
macro_rules! COPT_DIRNAMES {
- () => {
- 1<<3
- }
+ () => {
+ 1 << 3
+ };
}
#[macro_export]
macro_rules! COPT_NOQUOTE {
- () => {
- 1<<4
- }
+ () => {
+ 1 << 4
+ };
}
#[macro_export]
macro_rules! COPT_NOSPACE {
- () => {
- 1<<5
- }
+ () => {
+ 1 << 5
+ };
}
#[macro_export]
macro_rules! COPT_BASHDEFAULT {
- () => {
- 1<<6
- }
+ () => {
+ 1 << 6
+ };
}
#[macro_export]
macro_rules! COPT_PLUSDIRS {
- () => {
- 1<<7
- }
+ () => {
+ 1 << 7
+ };
}
#[macro_export]
macro_rules! COPT_NOSORT {
- () => {
- 1<<8
- }
+ () => {
+ 1 << 8
+ };
}
#[macro_export]
macro_rules! RL_STATE_COMPLETING {
- () => {
- 0x0004000 /* doing completion */
- }
+ () => {
+ 0x0004000 /* doing completion */
+ };
}
extern "C" {
- fn reset_internal_getopt();
- fn internal_getopt (list:*mut WordList , opts:*mut c_char)->i32;
- fn sh_invalidopt (value:* mut c_char);
- fn sh_invalidid (value:* mut c_char);
- fn sh_invalidoptname (value:* mut c_char);
- fn builtin_usage();
- static list_optarg:* mut c_char;
- fn builtin_error(err:*const c_char,...);
- fn check_identifier (w:* mut WordDesc, f:i32)->i32;
- static mut posixly_correct:i32;
- static mut loptend:*mut WordList;
- fn make_word_list (w:* mut WordDesc, list:*mut WordList)->*mut WordList;
- fn make_bare_word (w:*const c_char)->* mut WordDesc;
- fn dispose_words (list:*mut WordList);
- fn progcomp_flush ();
- fn compspec_create ()->* mut COMPSPEC;
- fn progcomp_insert (str:* mut c_char, c:* mut COMPSPEC)->i32;
- fn progcomp_remove (str:* mut c_char)->i32;
- fn sh_single_quote (str:* mut c_char)->* mut c_char;
- fn progcomp_walk (func: unsafe extern "C" fn (item:* mut BUCKET_CONTENTS)->i32);
- fn sh_chkwrite (i:i32)->i32;
- fn progcomp_search (w:*const c_char)->* mut COMPSPEC;
- static mut pcomp_line:* mut c_char;
- static mut pcomp_ind:c_int;
- fn gen_compspec_completions (cs:* mut COMPSPEC, cmd:*const c_char, word:*const c_char, start:i32, end:i32, foundp:* mut i32)->* mut STRINGLIST;
- fn bash_default_completion (text:* const c_char, start:i32, end:i32, qc:i32, compflags:i32)->* mut * mut c_char;
- fn rl_filename_completion_function (text:* const c_char, state:i32)-> * mut c_char;
- fn rl_completion_matches (text:* const c_char, entry_function:unsafe extern "C" fn (text:* const c_char, state:i32)-> * mut c_char)->* mut * mut c_char;
- fn completions_to_stringlist (matches:* mut * mut c_char)->* mut STRINGLIST;
- fn strvec_dispose (matches:* mut * mut c_char);
- fn strlist_dispose (strlist:* mut STRINGLIST);
- fn strlist_print (strlist:* mut STRINGLIST, text:* mut c_char);
- fn compspec_dispose (com:* mut COMPSPEC);
- static mut list_opttype:i32;
- static mut rl_readline_state:c_ulong;
- static mut pcomp_curcs:* mut COMPSPEC;
- static pcomp_curcmd:* mut c_char;
- fn pcomp_set_compspec_options (cs:* mut COMPSPEC, flags:i32, set_or_unset:i32);
- fn pcomp_set_readline_variables (flags:i32, nval:i32);
-}
-
-pub static mut Garg:* mut c_char=std::ptr::null_mut();
-pub static mut Warg:* mut c_char=std::ptr::null_mut();
-pub static mut Parg:* mut c_char=std::ptr::null_mut();
-pub static mut Sarg:* mut c_char=std::ptr::null_mut();
-pub static mut Xarg:* mut c_char=std::ptr::null_mut();
-pub static mut Farg:* mut c_char=std::ptr::null_mut();
-pub static mut Carg:* mut c_char=std::ptr::null_mut();
-
-unsafe fn STRDUP(x:* const c_char)->* mut c_char
-{
- if x !=std::ptr::null_mut() {
- return r_savestring (x);
- } else {
- return std::ptr::null_mut();
- }
-}
-
-unsafe fn STREQ( a:* const c_char, b:* const c_char)->bool
-{
- return *a ==*b && libc::strcmp(a, b) == 0;
-}
-
-unsafe fn shell_break_chars()->* const c_char
-{
- return b"()<>;&| \t\n\0".as_ptr() as *const c_char;
-}
-
-unsafe fn EMPTYCMD()->* const c_char
-{
- return b"_EmptycmD_\0".as_ptr() as *const c_char;
-}
-
-unsafe fn DEFAULTCMD()->* const c_char
-{
- return b"_DefaultCmD_\0".as_ptr() as *const c_char;
-}
-
-unsafe fn INITIALWORD()->* const c_char
-{
- return b"_InitialWorD_\0".as_ptr() as *const c_char;
-}
-
-unsafe fn RL_ISSTATE(x:c_ulong)->c_ulong
-{
- return rl_readline_state & x;
+ fn reset_internal_getopt();
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
+ fn sh_invalidopt(value: *mut c_char);
+ fn sh_invalidid(value: *mut c_char);
+ fn sh_invalidoptname(value: *mut c_char);
+ fn builtin_usage();
+ static list_optarg: *mut c_char;
+ fn builtin_error(err: *const c_char, ...);
+ fn check_identifier(w: *mut WordDesc, f: i32) -> i32;
+ static mut posixly_correct: i32;
+ static mut loptend: *mut WordList;
+ fn make_word_list(w: *mut WordDesc, list: *mut WordList) -> *mut WordList;
+ fn make_bare_word(w: *const c_char) -> *mut WordDesc;
+ fn dispose_words(list: *mut WordList);
+ fn progcomp_flush();
+ fn compspec_create() -> *mut COMPSPEC;
+ fn progcomp_insert(str: *mut c_char, c: *mut COMPSPEC) -> i32;
+ fn progcomp_remove(str: *mut c_char) -> i32;
+ fn sh_single_quote(str: *mut c_char) -> *mut c_char;
+ fn progcomp_walk(func: unsafe extern "C" fn(item: *mut BUCKET_CONTENTS) -> i32);
+ fn sh_chkwrite(i: i32) -> i32;
+ fn progcomp_search(w: *const c_char) -> *mut COMPSPEC;
+ static mut pcomp_line: *mut c_char;
+ static mut pcomp_ind: c_int;
+ fn gen_compspec_completions(
+ cs: *mut COMPSPEC,
+ cmd: *const c_char,
+ word: *const c_char,
+ start: i32,
+ end: i32,
+ foundp: *mut i32,
+ ) -> *mut STRINGLIST;
+ fn bash_default_completion(
+ text: *const c_char,
+ start: i32,
+ end: i32,
+ qc: i32,
+ compflags: i32,
+ ) -> *mut *mut c_char;
+ fn rl_filename_completion_function(text: *const c_char, state: i32) -> *mut c_char;
+ fn rl_completion_matches(
+ text: *const c_char,
+ entry_function: unsafe extern "C" fn(text: *const c_char, state: i32) -> *mut c_char,
+ ) -> *mut *mut c_char;
+ fn completions_to_stringlist(matches: *mut *mut c_char) -> *mut STRINGLIST;
+ fn strvec_dispose(matches: *mut *mut c_char);
+ fn strlist_dispose(strlist: *mut STRINGLIST);
+ fn strlist_print(strlist: *mut STRINGLIST, text: *mut c_char);
+ fn compspec_dispose(com: *mut COMPSPEC);
+ static mut list_opttype: i32;
+ static mut rl_readline_state: c_ulong;
+ static mut pcomp_curcs: *mut COMPSPEC;
+ static pcomp_curcmd: *mut c_char;
+ fn pcomp_set_compspec_options(cs: *mut COMPSPEC, flags: i32, set_or_unset: i32);
+ fn pcomp_set_readline_variables(flags: i32, nval: i32);
+}
+
+pub static mut Garg: *mut c_char = std::ptr::null_mut();
+pub static mut Warg: *mut c_char = std::ptr::null_mut();
+pub static mut Parg: *mut c_char = std::ptr::null_mut();
+pub static mut Sarg: *mut c_char = std::ptr::null_mut();
+pub static mut Xarg: *mut c_char = std::ptr::null_mut();
+pub static mut Farg: *mut c_char = std::ptr::null_mut();
+pub static mut Carg: *mut c_char = std::ptr::null_mut();
+
+unsafe fn STRDUP(x: *const c_char) -> *mut c_char {
+ if x != std::ptr::null_mut() {
+ return r_savestring(x);
+ } else {
+ return std::ptr::null_mut();
+ }
+}
+
+unsafe fn STREQ(a: *const c_char, b: *const c_char) -> bool {
+ return *a == *b && libc::strcmp(a, b) == 0;
+}
+
+unsafe fn shell_break_chars() -> *const c_char {
+ return b"()<>;&| \t\n\0".as_ptr() as *const c_char;
+}
+
+unsafe fn EMPTYCMD() -> *const c_char {
+ return b"_EmptycmD_\0".as_ptr() as *const c_char;
+}
+
+unsafe fn DEFAULTCMD() -> *const c_char {
+ return b"_DefaultCmD_\0".as_ptr() as *const c_char;
+}
+
+unsafe fn INITIALWORD() -> *const c_char {
+ return b"_InitialWorD_\0".as_ptr() as *const c_char;
+}
+
+unsafe fn RL_ISSTATE(x: c_ulong) -> c_ulong {
+ return rl_readline_state & x;
}
#[no_mangle]
-pub extern "C" fn r_find_compact (name:* mut c_char)->i32
-{
- let mut i:i32=0;
- unsafe {
- let compacts:CompactsArray=CompactsArray::new();
- while compacts.compactsArr[i as usize].actname != std::ptr::null_mut() {
- let tmp = CStr::from_ptr(compacts.compactsArr[i as usize].actname);
- if STREQ (name, compacts.compactsArr[i as usize].actname) {
- return i;
- }
- i+=1;
+pub extern "C" fn r_find_compact(name: *mut c_char) -> i32 {
+ let mut i: i32 = 0;
+ unsafe {
+ let compacts: CompactsArray = CompactsArray::new();
+ while compacts.compactsArr[i as usize].actname != std::ptr::null_mut() {
+ let tmp = CStr::from_ptr(compacts.compactsArr[i as usize].actname);
+ if STREQ(name, compacts.compactsArr[i as usize].actname) {
+ return i;
+ }
+ i += 1;
+ }
+ return -1;
}
- return -1;
- }
}
#[no_mangle]
-pub extern "C" fn r_find_compopt (name:* mut c_char)->i32
-{
- let mut i:i32=0;
- let compopts:CompoptArray=CompoptArray::new();
- unsafe {
- while compopts.compoptArr[i as usize].optname != std::ptr::null_mut() {
- if STREQ (name, compopts.compoptArr[i as usize].optname) {
- return i;
- }
- i+=1;
+pub extern "C" fn r_find_compopt(name: *mut c_char) -> i32 {
+ let mut i: i32 = 0;
+ let compopts: CompoptArray = CompoptArray::new();
+ unsafe {
+ while compopts.compoptArr[i as usize].optname != std::ptr::null_mut() {
+ if STREQ(name, compopts.compoptArr[i as usize].optname) {
+ return i;
+ }
+ i += 1;
+ }
+ return -1;
}
- return -1;
- }
}
#[no_mangle]
-pub extern "C" fn r_build_actions (mut list : *mut WordList, flagp:* mut _optflags, actp:* mut c_ulong, optp:* mut c_ulong)->i32
-{
- let mut opt:i32;
- let mut ind:i32;
- let mut opt_given:i32=0;
- let mut acts:c_ulong=0;
- let mut copts:c_ulong=0;
- let mut w:WordDesc=WordDesc{word:std::ptr::null_mut(),flags:0};
-
- unsafe {
- reset_internal_getopt ();
- opt = internal_getopt(list, CString::new("abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI").unwrap().as_ptr() as * mut c_char);
- while opt != -1 {
- opt_given = 1;
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
- match optChar{
- 'r'=>{
- if flagp !=std::ptr::null_mut() {
- (*flagp).rflag = 1;
- } else {
- sh_invalidopt (CString::new("-r").unwrap().as_ptr() as * mut c_char);
- builtin_usage ();
- return EX_USAGE;
- }
- }
- 'p'=>{
- if flagp !=std::ptr::null_mut() {
- (*flagp).pflag = 1;
- } else {
- sh_invalidopt (CString::new("-p").unwrap().as_ptr() as * mut c_char);
- builtin_usage ();
- return EX_USAGE;
- }
- }
- 'a'=>{
- acts |= CA_ALIAS!();
- }
- 'b'=>{
- acts |= CA_BUILTIN!();
- }
- 'c'=>{
- acts |= CA_COMMAND!();
- }
- 'd'=>{
- acts |= CA_DIRECTORY!();
- }
- 'e'=>{
- acts |= CA_EXPORT!();
- }
- 'f'=>{
- acts |= CA_FILE!();
- }
- 'g'=>{
- acts |= CA_GROUP!();
- }
- 'j'=>{
- acts |= CA_GROUP!();
- }
- 'k'=>{
- acts |= CA_KEYWORD!();
- }
- 's'=>{
- acts |= CA_SERVICE!();
- }
- 'u'=>{
- acts |= CA_USER!();
- }
- 'v'=>{
- acts |= CA_VARIABLE!();
- }
- 'o'=>{
- ind = r_find_compopt (list_optarg);
- if ind < 0 {
- sh_invalidoptname (list_optarg);
- return EX_USAGE;
- }
- let compopts:CompoptArray=CompoptArray::new();
- copts |= compopts.compoptArr[ind as usize].optflag;
- }
- 'A'=>{
- ind = r_find_compact (list_optarg);
- if ind < 0 {
- builtin_error (CString::new("%s: invalid action name").unwrap().as_ptr(), list_optarg);
- return EX_USAGE;
- }
- let compacts:CompactsArray=CompactsArray::new();
- acts |= compacts.compactsArr[ind as usize].actflag;
- }
- 'C'=>{
- Carg = list_optarg;
- }
- 'D'=>{
- if flagp !=std::ptr::null_mut() {
- (*flagp).Dflag = 1;
- } else {
- sh_invalidopt (CString::new("-D").unwrap().as_ptr() as * mut c_char);
- builtin_usage ();
- return EX_USAGE;
- }
- }
- 'E'=>{
- if flagp !=std::ptr::null_mut() {
- (*flagp).Eflag = 1;
- } else {
- sh_invalidopt (CString::new("-E").unwrap().as_ptr() as * mut c_char);
- builtin_usage ();
- return EX_USAGE;
- }
- }
- 'I'=>{
- if flagp !=std::ptr::null_mut() {
- (*flagp).Iflag = 1;
- } else {
- sh_invalidopt (CString::new("-I").unwrap().as_ptr() as * mut c_char);
- builtin_usage ();
- return EX_USAGE;
+pub extern "C" fn r_build_actions(
+ mut list: *mut WordList,
+ flagp: *mut _optflags,
+ actp: *mut c_ulong,
+ optp: *mut c_ulong,
+) -> i32 {
+ let mut opt: i32;
+ let mut ind: i32;
+ let mut opt_given: i32 = 0;
+ let mut acts: c_ulong = 0;
+ let mut copts: c_ulong = 0;
+ let mut w: WordDesc = WordDesc {
+ word: std::ptr::null_mut(),
+ flags: 0,
+ };
+
+ unsafe {
+ reset_internal_getopt();
+ opt = internal_getopt(
+ list,
+ CString::new("abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI")
+ .unwrap()
+ .as_ptr() as *mut c_char,
+ );
+ while opt != -1 {
+ opt_given = 1;
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'r' => {
+ if flagp != std::ptr::null_mut() {
+ (*flagp).rflag = 1;
+ } else {
+ sh_invalidopt(CString::new("-r").unwrap().as_ptr() as *mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ 'p' => {
+ if flagp != std::ptr::null_mut() {
+ (*flagp).pflag = 1;
+ } else {
+ sh_invalidopt(CString::new("-p").unwrap().as_ptr() as *mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ 'a' => {
+ acts |= CA_ALIAS!();
+ }
+ 'b' => {
+ acts |= CA_BUILTIN!();
+ }
+ 'c' => {
+ acts |= CA_COMMAND!();
+ }
+ 'd' => {
+ acts |= CA_DIRECTORY!();
+ }
+ 'e' => {
+ acts |= CA_EXPORT!();
+ }
+ 'f' => {
+ acts |= CA_FILE!();
+ }
+ 'g' => {
+ acts |= CA_GROUP!();
+ }
+ 'j' => {
+ acts |= CA_GROUP!();
+ }
+ 'k' => {
+ acts |= CA_KEYWORD!();
+ }
+ 's' => {
+ acts |= CA_SERVICE!();
+ }
+ 'u' => {
+ acts |= CA_USER!();
+ }
+ 'v' => {
+ acts |= CA_VARIABLE!();
+ }
+ 'o' => {
+ ind = r_find_compopt(list_optarg);
+ if ind < 0 {
+ sh_invalidoptname(list_optarg);
+ return EX_USAGE;
+ }
+ let compopts: CompoptArray = CompoptArray::new();
+ copts |= compopts.compoptArr[ind as usize].optflag;
+ }
+ 'A' => {
+ ind = r_find_compact(list_optarg);
+ if ind < 0 {
+ builtin_error(
+ CString::new("%s: invalid action name").unwrap().as_ptr(),
+ list_optarg,
+ );
+ return EX_USAGE;
+ }
+ let compacts: CompactsArray = CompactsArray::new();
+ acts |= compacts.compactsArr[ind as usize].actflag;
+ }
+ 'C' => {
+ Carg = list_optarg;
+ }
+ 'D' => {
+ if flagp != std::ptr::null_mut() {
+ (*flagp).Dflag = 1;
+ } else {
+ sh_invalidopt(CString::new("-D").unwrap().as_ptr() as *mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ 'E' => {
+ if flagp != std::ptr::null_mut() {
+ (*flagp).Eflag = 1;
+ } else {
+ sh_invalidopt(CString::new("-E").unwrap().as_ptr() as *mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ 'I' => {
+ if flagp != std::ptr::null_mut() {
+ (*flagp).Iflag = 1;
+ } else {
+ sh_invalidopt(CString::new("-I").unwrap().as_ptr() as *mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ 'F' => {
+ w.word = list_optarg;
+ Farg = list_optarg;
+ w.flags = 0;
+ if check_identifier(&mut w, posixly_correct) == 0
+ || libc::strpbrk(Farg, shell_break_chars()) != std::ptr::null_mut()
+ {
+ sh_invalidid(Farg);
+ return EX_USAGE;
+ }
+ }
+ 'G' => {
+ Garg = list_optarg;
+ }
+ 'P' => {
+ Parg = list_optarg;
+ }
+ 'S' => {
+ Sarg = list_optarg;
+ }
+ 'W' => {
+ Warg = list_optarg;
+ }
+ 'X' => {
+ Xarg = list_optarg;
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
+ return EX_USAGE;
+ }
}
- }
- 'F'=>{
- w.word = list_optarg;
- Farg = list_optarg;
- w.flags = 0;
- if check_identifier (&mut w, posixly_correct) == 0 || libc::strpbrk (Farg, shell_break_chars()) != std::ptr::null_mut() {
- sh_invalidid (Farg);
- return EX_USAGE;
- }
- }
- 'G'=>{
- Garg = list_optarg;
- }
- 'P'=>{
- Parg = list_optarg;
- }
- 'S'=>{
- Sarg = list_optarg;
- }
- 'W'=>{
- Warg = list_optarg;
- }
- 'X'=>{
- Xarg = list_optarg;
- }
- _=>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
- }
- builtin_usage ();
- return EX_USAGE;
- }
+ opt = internal_getopt(
+ list,
+ CString::new("abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI")
+ .unwrap()
+ .as_ptr() as *mut c_char,
+ );
}
- opt=internal_getopt(list, CString::new("abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI").unwrap().as_ptr() as * mut c_char);
- }
- *actp = acts;
- *optp = copts;
- list = loptend.clone();
- if opt_given !=0 {
- return EXECUTION_SUCCESS!();
- } else {
- return EXECUTION_FAILURE!();
- }
- }
+ *actp = acts;
+ *optp = copts;
+ list = loptend.clone();
+ if opt_given != 0 {
+ return EXECUTION_SUCCESS!();
+ } else {
+ return EXECUTION_FAILURE!();
+ }
+ }
}
/* Add, remove, and display completion specifiers. */
#[no_mangle]
-pub extern "C" fn r_complete_builtin (listt: *mut WordList)->i32
-{
- let mut opt_given:i32=0;
- let mut rval:i32;
- let mut acts:c_ulong=0;
- let mut copts:c_ulong=0;
- let mut cs:* mut COMPSPEC;
- let mut oflags:_optflags=_optflags{pflag:0,rflag:0,Dflag:0,Eflag:0,Iflag:0};
- let mut l: *mut WordList;
- let mut wl: *mut WordList;
-
- unsafe {
- let mut list:* mut WordList=listt.clone();
- if list == std::ptr::null_mut() {
- r_print_all_completions ();
- return EXECUTION_SUCCESS!();
- }
+pub extern "C" fn r_complete_builtin(listt: *mut WordList) -> i32 {
+ let mut opt_given: i32 = 0;
+ let mut rval: i32;
+ let mut acts: c_ulong = 0;
+ let mut copts: c_ulong = 0;
+ let mut cs: *mut COMPSPEC;
+ let mut oflags: _optflags = _optflags {
+ pflag: 0,
+ rflag: 0,
+ Dflag: 0,
+ Eflag: 0,
+ Iflag: 0,
+ };
+ let mut l: *mut WordList;
+ let mut wl: *mut WordList;
+
+ unsafe {
+ let mut list: *mut WordList = listt.clone();
+ if list == std::ptr::null_mut() {
+ r_print_all_completions();
+ return EXECUTION_SUCCESS!();
+ }
- oflags.pflag=0;
- oflags.rflag=0;
- oflags.Dflag=0;
- oflags.Eflag=0;
- oflags.Iflag=0;
-
- Garg=std::ptr::null_mut();
- Warg=std::ptr::null_mut();
- Parg=std::ptr::null_mut();
- Sarg=std::ptr::null_mut();
- Xarg=std::ptr::null_mut();
- Farg=std::ptr::null_mut();
- Carg=std::ptr::null_mut();
-
- cs=std::ptr::null_mut();
-
- /* Build the actions from the arguments. Also sets the [A-Z]arg variables
- as a side effect if they are supplied as options. */
- rval = r_build_actions (list, &mut oflags, &mut acts, &mut copts);
- if rval == EX_USAGE {
- return rval;
- }
+ oflags.pflag = 0;
+ oflags.rflag = 0;
+ oflags.Dflag = 0;
+ oflags.Eflag = 0;
+ oflags.Iflag = 0;
+
+ Garg = std::ptr::null_mut();
+ Warg = std::ptr::null_mut();
+ Parg = std::ptr::null_mut();
+ Sarg = std::ptr::null_mut();
+ Xarg = std::ptr::null_mut();
+ Farg = std::ptr::null_mut();
+ Carg = std::ptr::null_mut();
+
+ cs = std::ptr::null_mut();
+
+ /* Build the actions from the arguments. Also sets the [A-Z]arg variables
+ as a side effect if they are supplied as options. */
+ rval = r_build_actions(list, &mut oflags, &mut acts, &mut copts);
+ if rval == EX_USAGE {
+ return rval;
+ }
- opt_given = (rval != EXECUTION_FAILURE!()) as i32;
+ opt_given = (rval != EXECUTION_FAILURE!()) as i32;
- list = loptend.clone();
+ list = loptend.clone();
- if oflags.Dflag !=0 {
- wl = make_word_list (make_bare_word (DEFAULTCMD()), std::ptr::null_mut());
- } else if oflags.Eflag !=0 {
- wl = make_word_list (make_bare_word (EMPTYCMD()), std::ptr::null_mut());
- } else if oflags.Iflag !=0 {
- wl = make_word_list (make_bare_word (INITIALWORD()), std::ptr::null_mut());
- } else {
- wl = std::ptr::null_mut();
- }
+ if oflags.Dflag != 0 {
+ wl = make_word_list(make_bare_word(DEFAULTCMD()), std::ptr::null_mut());
+ } else if oflags.Eflag != 0 {
+ wl = make_word_list(make_bare_word(EMPTYCMD()), std::ptr::null_mut());
+ } else if oflags.Iflag != 0 {
+ wl = make_word_list(make_bare_word(INITIALWORD()), std::ptr::null_mut());
+ } else {
+ wl = std::ptr::null_mut();
+ }
- /* -p overrides everything else */
- if oflags.pflag !=0 || (list == std::ptr::null_mut() && opt_given == 0) {
- if wl != std::ptr::null_mut() {
- rval = r_print_cmd_completions (wl);
- dispose_words (wl);
- return rval;
- } else if list == std::ptr::null_mut() {
- //给了P,但没给参数,直接打印全部并退出
- r_print_all_completions ();
- return EXECUTION_SUCCESS!();
+ /* -p overrides everything else */
+ if oflags.pflag != 0 || (list == std::ptr::null_mut() && opt_given == 0) {
+ if wl != std::ptr::null_mut() {
+ rval = r_print_cmd_completions(wl);
+ dispose_words(wl);
+ return rval;
+ } else if list == std::ptr::null_mut() {
+ //给了P,但没给参数,直接打印全部并退出
+ r_print_all_completions();
+ return EXECUTION_SUCCESS!();
+ }
+ return r_print_cmd_completions(list);
}
- return r_print_cmd_completions (list);
- }
- /* next, -r overrides everything else. */
- if oflags.rflag !=0 {
- if wl != std::ptr::null_mut() {
- rval = r_remove_cmd_completions (wl);
- dispose_words (wl);
- return rval;
- } else if list == std::ptr::null_mut() {
- progcomp_flush ();
- return EXECUTION_SUCCESS!();
+ /* next, -r overrides everything else. */
+ if oflags.rflag != 0 {
+ if wl != std::ptr::null_mut() {
+ rval = r_remove_cmd_completions(wl);
+ dispose_words(wl);
+ return rval;
+ } else if list == std::ptr::null_mut() {
+ progcomp_flush();
+ return EXECUTION_SUCCESS!();
+ }
+ return r_remove_cmd_completions(list);
}
- return r_remove_cmd_completions (list);
- }
- if wl == std::ptr::null_mut() && list == std::ptr::null_mut() && opt_given !=0 {
- builtin_usage ();
- return EX_USAGE;
- }
+ if wl == std::ptr::null_mut() && list == std::ptr::null_mut() && opt_given != 0 {
+ builtin_usage();
+ return EX_USAGE;
+ }
- /* If we get here, we need to build a compspec and add it for each
- remaining argument. */
- cs = compspec_create ();
- (*cs).actions = acts;
- (*cs).options = copts;
+ /* If we get here, we need to build a compspec and add it for each
+ remaining argument. */
+ cs = compspec_create();
+ (*cs).actions = acts;
+ (*cs).options = copts;
- (*cs).globpat = STRDUP (Garg);
- (*cs).words = STRDUP (Warg);
- (*cs).prefix = STRDUP (Parg);
- (*cs).suffix = STRDUP (Sarg);
- (*cs).funcname = STRDUP (Farg);
- (*cs).command = STRDUP (Carg);
- (*cs).filterpat = STRDUP (Xarg);
+ (*cs).globpat = STRDUP(Garg);
+ (*cs).words = STRDUP(Warg);
+ (*cs).prefix = STRDUP(Parg);
+ (*cs).suffix = STRDUP(Sarg);
+ (*cs).funcname = STRDUP(Farg);
+ (*cs).command = STRDUP(Carg);
+ (*cs).filterpat = STRDUP(Xarg);
- rval = EXECUTION_SUCCESS!();
+ rval = EXECUTION_SUCCESS!();
- if wl != std::ptr::null_mut() {
- l= wl.clone();
- } else {
- l= list.clone();
- }
+ if wl != std::ptr::null_mut() {
+ l = wl.clone();
+ } else {
+ l = list.clone();
+ }
- while l != std::ptr::null_mut() {
- /* Add CS as the compspec for the specified commands. */
- if progcomp_insert ((*(*l).word).word, cs) == 0 {
- rval = EXECUTION_FAILURE!();
- }
- l = (*l).next;
- }
+ while l != std::ptr::null_mut() {
+ /* Add CS as the compspec for the specified commands. */
+ if progcomp_insert((*(*l).word).word, cs) == 0 {
+ rval = EXECUTION_FAILURE!();
+ }
+ l = l.next;
+ }
- dispose_words (wl);
- return rval;
- }
+ dispose_words(wl);
+ return rval;
+ }
}
#[no_mangle]
-pub extern "C" fn r_remove_cmd_completions (list: * mut WordList)->i32
-{
- let mut l:* mut WordList;
- let mut ret:i32;
- unsafe {
- ret = EXECUTION_SUCCESS!();
- l = list.clone();
- while l!=std::ptr::null_mut() {
- if progcomp_remove ((*(*l).word).word) == 0 {
- builtin_error (CString::new("%s: no completion specification").unwrap().as_ptr(), (*(*l).word).word);
- ret = EXECUTION_FAILURE!();
- }
- l = (*l).next;
+pub extern "C" fn r_remove_cmd_completions(list: *mut WordList) -> i32 {
+ let mut l: *mut WordList;
+ let mut ret: i32;
+ unsafe {
+ ret = EXECUTION_SUCCESS!();
+ l = list.clone();
+ while l != std::ptr::null_mut() {
+ if progcomp_remove((*(*l).word).word) == 0 {
+ builtin_error(
+ CString::new("%s: no completion specification")
+ .unwrap()
+ .as_ptr(),
+ (*(*l).word).word,
+ );
+ ret = EXECUTION_FAILURE!();
+ }
+ l = (*l).next;
+ }
+ return ret;
}
- return ret;
- }
}
#[no_mangle]
-pub extern "C" fn r_print_compoptions (copts:c_ulong, full:i32)
-{
- unsafe {
- let compopts:CompoptArray=CompoptArray::new();
- for i in 0..compopts.compoptArr.len() {
- if (copts & compopts.compoptArr[i].optflag) !=0 {
- libc::printf (CString::new("-o %s ").unwrap().as_ptr(), compopts.compoptArr[i].optname);
- } else if full !=0 {
- libc::printf (CString::new("+o %s ").unwrap().as_ptr(), compopts.compoptArr[i].optname);
- }
+pub extern "C" fn r_print_compoptions(copts: c_ulong, full: i32) {
+ unsafe {
+ let compopts: CompoptArray = CompoptArray::new();
+ for i in 0..compopts.compoptArr.len() {
+ if (copts & compopts.compoptArr[i].optflag) != 0 {
+ libc::printf(
+ CString::new("-o %s ").unwrap().as_ptr(),
+ compopts.compoptArr[i].optname,
+ );
+ } else if full != 0 {
+ libc::printf(
+ CString::new("+o %s ").unwrap().as_ptr(),
+ compopts.compoptArr[i].optname,
+ );
+ }
+ }
}
- }
}
#[no_mangle]
-pub extern "C" fn r_print_compactions (acts:c_ulong)
-{
- unsafe {
- let compacts:CompactsArray=CompactsArray::new();
- for i in 0..compacts.compactsArr.len() {
- if compacts.compactsArr[i].actopt !=0 && (acts & compacts.compactsArr[i].actflag) !=0 {
- libc::printf (CString::new("-%c ").unwrap().as_ptr(), compacts.compactsArr[i].actopt);
- }
- }
+pub extern "C" fn r_print_compactions(acts: c_ulong) {
+ unsafe {
+ let compacts: CompactsArray = CompactsArray::new();
+ for i in 0..compacts.compactsArr.len() {
+ if compacts.compactsArr[i].actopt != 0 && (acts & compacts.compactsArr[i].actflag) != 0
+ {
+ libc::printf(
+ CString::new("-%c ").unwrap().as_ptr(),
+ compacts.compactsArr[i].actopt,
+ );
+ }
+ }
- for i in 0..compacts.compactsArr.len() {
- if compacts.compactsArr[i].actopt ==0 && (acts & compacts.compactsArr[i].actflag) !=0 {
- libc::printf (CString::new("-A %s ").unwrap().as_ptr(), compacts.compactsArr[i].actname);
- }
+ for i in 0..compacts.compactsArr.len() {
+ if compacts.compactsArr[i].actopt == 0 && (acts & compacts.compactsArr[i].actflag) != 0
+ {
+ libc::printf(
+ CString::new("-A %s ").unwrap().as_ptr(),
+ compacts.compactsArr[i].actname,
+ );
+ }
+ }
}
- }
}
#[no_mangle]
-pub extern "C" fn r_print_arg (arg:* const c_char, flag:* const c_char, quote:i32)
-{
- let x:* mut c_char;
- unsafe {
- if arg != std::ptr::null_mut() {
- if quote !=0 {
- // 复制arg 增加单引号返给x
- x = sh_single_quote (arg as * mut c_char);
- } else {
- x= arg as * mut c_char;
- }
- libc::printf (CString::new("%s %s ").unwrap().as_ptr(), flag, x);
- if x != arg as * mut c_char {
- libc::free (x as * mut c_void);
+pub extern "C" fn r_print_arg(arg: *const c_char, flag: *const c_char, quote: i32) {
+ let x: *mut c_char;
+ unsafe {
+ if arg != std::ptr::null_mut() {
+ if quote != 0 {
+ // 复制arg 增加单引号返给x
+ x = sh_single_quote(arg as *mut c_char);
+ } else {
+ x = arg as *mut c_char;
+ }
+ libc::printf(CString::new("%s %s ").unwrap().as_ptr(), flag, x);
+ if x != arg as *mut c_char {
+ libc::free(x as *mut c_void);
+ }
}
}
- }
}
#[no_mangle]
-pub extern "C" fn r_print_cmd_name (cmd:* const c_char)
-{
- unsafe {
- if STREQ (cmd, DEFAULTCMD()) {
- libc::printf (CString::new("-D").unwrap().as_ptr());
- } else if STREQ (cmd, EMPTYCMD()) {
- libc::printf (CString::new("-E").unwrap().as_ptr());
- } else if STREQ (cmd, INITIALWORD()) {
- libc::printf (CString::new("-I").unwrap().as_ptr());
- } else if *cmd == 0 { /* XXX - can this happen? */
- libc::printf (CString::new("''").unwrap().as_ptr());
- } else {
- libc::printf (CString::new("%s").unwrap().as_ptr(),cmd);
+pub extern "C" fn r_print_cmd_name(cmd: *const c_char) {
+ unsafe {
+ if STREQ(cmd, DEFAULTCMD()) {
+ libc::printf(CString::new("-D").unwrap().as_ptr());
+ } else if STREQ(cmd, EMPTYCMD()) {
+ libc::printf(CString::new("-E").unwrap().as_ptr());
+ } else if STREQ(cmd, INITIALWORD()) {
+ libc::printf(CString::new("-I").unwrap().as_ptr());
+ } else if *cmd == 0 {
+ /* XXX - can this happen? */
+ libc::printf(CString::new("''").unwrap().as_ptr());
+ } else {
+ libc::printf(CString::new("%s").unwrap().as_ptr(), cmd);
+ }
}
- }
}
#[no_mangle]
-pub extern "C" fn r_print_one_completion (cmd: * mut c_char, cs:* mut COMPSPEC)->i32
-{
- unsafe {
- libc::printf (CString::new("complete ").unwrap().as_ptr());
+pub extern "C" fn r_print_one_completion(cmd: *mut c_char, cs: *mut COMPSPEC) -> i32 {
+ unsafe {
+ libc::printf(CString::new("complete ").unwrap().as_ptr());
- r_print_compoptions ((*cs).options, 0);
- r_print_compactions ((*cs).actions);
+ r_print_compoptions((*cs).options, 0);
+ r_print_compactions((*cs).actions);
- /* now the rest of the arguments */
+ /* now the rest of the arguments */
- /* arguments that require quoting */
- r_print_arg ((*cs).globpat, CString::new("-G").unwrap().as_ptr(), 1);
- r_print_arg ((*cs).words, CString::new("-W").unwrap().as_ptr(), 1);
- r_print_arg ((*cs).prefix, CString::new("-P").unwrap().as_ptr(), 1);
- r_print_arg ((*cs).suffix, CString::new("-S").unwrap().as_ptr(), 1);
- r_print_arg ((*cs).filterpat, CString::new("-X").unwrap().as_ptr(), 1);
+ /* arguments that require quoting */
+ r_print_arg((*cs).globpat, CString::new("-G").unwrap().as_ptr(), 1);
+ r_print_arg((*cs).words, CString::new("-W").unwrap().as_ptr(), 1);
+ r_print_arg((*cs).prefix, CString::new("-P").unwrap().as_ptr(), 1);
+ r_print_arg((*cs).suffix, CString::new("-S").unwrap().as_ptr(), 1);
+ r_print_arg((*cs).filterpat, CString::new("-X").unwrap().as_ptr(), 1);
- r_print_arg ((*cs).command, CString::new("-C").unwrap().as_ptr(), 1);
+ r_print_arg((*cs).command, CString::new("-C").unwrap().as_ptr(), 1);
- /* simple arguments that don't require quoting */
- r_print_arg ((*cs).funcname, CString::new("-F").unwrap().as_ptr(), 0);
+ /* simple arguments that don't require quoting */
+ r_print_arg((*cs).funcname, CString::new("-F").unwrap().as_ptr(), 0);
- r_print_cmd_name (cmd);
- libc::printf (CString::new("\n").unwrap().as_ptr());
+ r_print_cmd_name(cmd);
+ libc::printf(CString::new("\n").unwrap().as_ptr());
- return 0;
- }
+ return 0;
+ }
}
#[no_mangle]
-pub extern "C" fn r_print_compopts (cmd:* mut c_char, cs:* mut COMPSPEC, full:i32)
-{
- unsafe {
- libc::printf (CString::new("compopt ").unwrap().as_ptr());
+pub extern "C" fn r_print_compopts(cmd: *mut c_char, cs: *mut COMPSPEC, full: i32) {
+ unsafe {
+ libc::printf(CString::new("compopt ").unwrap().as_ptr());
- r_print_compoptions ((*cs).options, full);
- r_print_cmd_name (cmd);
+ r_print_compoptions((*cs).options, full);
+ r_print_cmd_name(cmd);
- libc::printf (CString::new("\n").unwrap().as_ptr());
- }
+ libc::printf(CString::new("\n").unwrap().as_ptr());
+ }
}
#[no_mangle]
-pub extern "C" fn r_print_compitem (item:* mut BUCKET_CONTENTS)->i32
-{
- let cs:* mut COMPSPEC;
- let cmd:* mut c_char;
- unsafe {
- cmd = (*item).key;
- cs = (*item).data as * mut COMPSPEC;
- }
+pub extern "C" fn r_print_compitem(item: *mut BUCKET_CONTENTS) -> i32 {
+ let cs: *mut COMPSPEC;
+ let cmd: *mut c_char;
+ unsafe {
+ cmd = (*item).key;
+ cs = (*item).data as *mut COMPSPEC;
+ }
- return r_print_one_completion (cmd, cs);
+ return r_print_one_completion(cmd, cs);
}
#[no_mangle]
-pub extern "C" fn r_print_all_completions ()
-{
- unsafe {
- progcomp_walk (r_print_compitem);
- }
+pub extern "C" fn r_print_all_completions() {
+ unsafe {
+ progcomp_walk(r_print_compitem);
+ }
}
#[no_mangle]
-pub extern "C" fn r_print_cmd_completions (list:* mut WordList)->i32
-{
- let mut l:* mut WordList;
- let mut cs:* mut COMPSPEC;
- let mut ret:i32;
-
- unsafe {
- ret = EXECUTION_SUCCESS!();
- l = list.clone();
- while l != std::ptr::null_mut() {
- cs = progcomp_search ((*(*l).word).word);
- if cs != std::ptr::null_mut() {
- r_print_one_completion ((*(*l).word).word, cs);
- } else {
- builtin_error (CString::new("%s: no completion specification").unwrap().as_ptr(),(*(*l).word).word);
- ret = EXECUTION_FAILURE!();
+pub extern "C" fn r_print_cmd_completions(list: *mut WordList) -> i32 {
+ let mut l: *mut WordList;
+ let mut cs: *mut COMPSPEC;
+ let mut ret: i32;
+
+ unsafe {
+ ret = EXECUTION_SUCCESS!();
+ l = list.clone();
+ while l != std::ptr::null_mut() {
+ cs = progcomp_search((*(*l).word).word);
+ if cs != std::ptr::null_mut() {
+ r_print_one_completion((*(*l).word).word, cs);
+ } else {
+ builtin_error(
+ CString::new("%s: no completion specification")
+ .unwrap()
+ .as_ptr(),
+ (*(*l).word).word,
+ );
+ ret = EXECUTION_FAILURE!();
+ }
+ l = (*l).next;
}
- l = (*l).next;
- }
- return sh_chkwrite (ret);
- }
+ return sh_chkwrite(ret);
+ }
}
#[no_mangle]
-pub extern "C" fn r_compgen_builtin (listt:* mut WordList)->i32
-{
- let mut rval:i32;
- let mut acts:c_ulong=0;
- let mut copts:c_ulong=0;
- let mut cs: * mut COMPSPEC;
- let mut sl:* mut STRINGLIST;
- let word:* mut c_char;
- let mut matches:* mut * mut c_char;
- let old_line:* mut c_char;
- let old_ind:i32;
- unsafe {
- let mut list:* mut WordList=listt.clone();
- if list == std::ptr::null_mut() {
- return EXECUTION_SUCCESS!();
- }
+pub extern "C" fn r_compgen_builtin(listt: *mut WordList) -> i32 {
+ let mut rval: i32;
+ let mut acts: c_ulong = 0;
+ let mut copts: c_ulong = 0;
+ let mut cs: *mut COMPSPEC;
+ let mut sl: *mut STRINGLIST;
+ let word: *mut c_char;
+ let mut matches: *mut *mut c_char;
+ let old_line: *mut c_char;
+ let old_ind: i32;
+ unsafe {
+ let mut list: *mut WordList = listt.clone();
+ if list == std::ptr::null_mut() {
+ return EXECUTION_SUCCESS!();
+ }
- Garg=std::ptr::null_mut();
- Warg=std::ptr::null_mut();
- Parg=std::ptr::null_mut();
- Sarg=std::ptr::null_mut();
- Xarg=std::ptr::null_mut();
- Farg=std::ptr::null_mut();
- Carg=std::ptr::null_mut();
+ Garg = std::ptr::null_mut();
+ Warg = std::ptr::null_mut();
+ Parg = std::ptr::null_mut();
+ Sarg = std::ptr::null_mut();
+ Xarg = std::ptr::null_mut();
+ Farg = std::ptr::null_mut();
+ Carg = std::ptr::null_mut();
- cs = std::ptr::null_mut();
+ cs = std::ptr::null_mut();
- /* Build the actions from the arguments. Also sets the [A-Z]arg variables
- as a side effect if they are supplied as options. */
- rval = r_build_actions (list, std::ptr::null_mut(), &mut acts, &mut copts);
- if rval == EX_USAGE {
- return rval;
- }
+ /* Build the actions from the arguments. Also sets the [A-Z]arg variables
+ as a side effect if they are supplied as options. */
+ rval = r_build_actions(list, std::ptr::null_mut(), &mut acts, &mut copts);
+ if rval == EX_USAGE {
+ return rval;
+ }
- if rval == EXECUTION_FAILURE!() {
- return EXECUTION_SUCCESS!();
- }
+ if rval == EXECUTION_FAILURE!() {
+ return EXECUTION_SUCCESS!();
+ }
- list = loptend.clone();
+ list = loptend.clone();
- let wordtmp=CString::new("").unwrap();
- if list !=std::ptr::null_mut() && (*list).word != std::ptr::null_mut() {
- word = (*((*list).word)).word;
- } else {
- word = wordtmp.as_ptr() as * mut c_char;
- }
+ let wordtmp = CString::new("").unwrap();
+ if list != std::ptr::null_mut() && (*list).word != std::ptr::null_mut() {
+ word = (*((*list).word)).word;
+ } else {
+ word = wordtmp.as_ptr() as *mut c_char;
+ }
- if Farg != std::ptr::null_mut() {
- builtin_error (CString::new("warning: -F option may not work as you expect").unwrap().as_ptr());
- }
+ if Farg != std::ptr::null_mut() {
+ builtin_error(
+ CString::new("warning: -F option may not work as you expect")
+ .unwrap()
+ .as_ptr(),
+ );
+ }
- if Carg != std::ptr::null_mut() {
- builtin_error (CString::new("warning: -C option may not work as you expect").unwrap().as_ptr());
- }
+ if Carg != std::ptr::null_mut() {
+ builtin_error(
+ CString::new("warning: -C option may not work as you expect")
+ .unwrap()
+ .as_ptr(),
+ );
+ }
- /* If we get here, we need to build a compspec and evaluate it. */
- cs = compspec_create ();
- (*cs).actions = acts;
- (*cs).options = copts;
- (*cs).refcount = 1;
-
- (*cs).globpat = STRDUP (Garg);
- (*cs).words = STRDUP (Warg);
- (*cs).prefix = STRDUP (Parg);
- (*cs).suffix = STRDUP (Sarg);
- (*cs).funcname = STRDUP (Farg);
- (*cs).command = STRDUP (Carg);
- (*cs).filterpat = STRDUP (Xarg);
-
- rval = EXECUTION_FAILURE!();
-
- /* probably don't have to save these, just being safe */
- old_line = pcomp_line;
- old_ind = pcomp_ind;
- pcomp_line = std::ptr::null_mut();
- pcomp_ind = 0;
- let compgenStr=CString::new("compgen").unwrap();
- sl = gen_compspec_completions (cs, compgenStr.as_ptr(), word, 0, 0, std::ptr::null_mut());
- pcomp_line = old_line;
- pcomp_ind = old_ind;
-
- /* If the compspec wants the bash default completions, temporarily
- turn off programmable completion and call the bash completion code. */
- if (sl == std::ptr::null_mut() || (*sl).list_len == 0) && (copts & COPT_BASHDEFAULT!()) !=0 {
- matches = bash_default_completion (word, 0, 0, 0, 0);
- sl = completions_to_stringlist (matches);
- strvec_dispose (matches);
- }
+ /* If we get here, we need to build a compspec and evaluate it. */
+ cs = compspec_create();
+ (*cs).actions = acts;
+ (*cs).options = copts;
+ (*cs).refcount = 1;
+
+ (*cs).globpat = STRDUP(Garg);
+ (*cs).words = STRDUP(Warg);
+ (*cs).prefix = STRDUP(Parg);
+ (*cs).suffix = STRDUP(Sarg);
+ (*cs).funcname = STRDUP(Farg);
+ (*cs).command = STRDUP(Carg);
+ (*cs).filterpat = STRDUP(Xarg);
+
+ rval = EXECUTION_FAILURE!();
+
+ /* probably don't have to save these, just being safe */
+ old_line = pcomp_line;
+ old_ind = pcomp_ind;
+ pcomp_line = std::ptr::null_mut();
+ pcomp_ind = 0;
+ let compgenStr = CString::new("compgen").unwrap();
+ sl = gen_compspec_completions(cs, compgenStr.as_ptr(), word, 0, 0, std::ptr::null_mut());
+ pcomp_line = old_line;
+ pcomp_ind = old_ind;
+
+ /* If the compspec wants the bash default completions, temporarily
+ turn off programmable completion and call the bash completion code. */
+ if (sl == std::ptr::null_mut() || (*sl).list_len == 0) && (copts & COPT_BASHDEFAULT!()) != 0
+ {
+ matches = bash_default_completion(word, 0, 0, 0, 0);
+ sl = completions_to_stringlist(matches);
+ strvec_dispose(matches);
+ }
- /* This isn't perfect, but it's the best we can do, given what readline
- exports from its set of completion utility functions. */
- if (sl == std::ptr::null_mut() || (*sl).list_len == 0) && (copts & COPT_DEFAULT!()) !=0 {
- matches = rl_completion_matches (word, rl_filename_completion_function);
- strlist_dispose (sl);
- sl = completions_to_stringlist (matches);
- strvec_dispose (matches);
- }
-
- if sl != std::ptr::null_mut() {
- if (*sl).list != std::ptr::null_mut() && (*sl).list_len !=0 {
- rval = EXECUTION_SUCCESS!();
- strlist_print (sl, std::ptr::null_mut());
+ /* This isn't perfect, but it's the best we can do, given what readline
+ exports from its set of completion utility functions. */
+ if (sl == std::ptr::null_mut() || (*sl).list_len == 0) && (copts & COPT_DEFAULT!()) != 0 {
+ matches = rl_completion_matches(word, rl_filename_completion_function);
+ strlist_dispose(sl);
+ sl = completions_to_stringlist(matches);
+ strvec_dispose(matches);
+ }
+
+ if sl != std::ptr::null_mut() {
+ if (*sl).list != std::ptr::null_mut() && (*sl).list_len != 0 {
+ rval = EXECUTION_SUCCESS!();
+ strlist_print(sl, std::ptr::null_mut());
+ }
+ strlist_dispose(sl);
}
- strlist_dispose (sl);
- }
- compspec_dispose (cs);
- return rval;
- }
+ compspec_dispose(cs);
+ return rval;
+ }
}
#[no_mangle]
-pub extern "C" fn r_compopt_builtin (listt:* mut WordList)->i32
-{
- let mut opts_on:i32=0;
- let mut opts_off:i32=0;
- let mut opts:* mut i32;
- let mut opt:i32;
- let mut oind:i32;
- let mut ret:i32;
- let mut Dflag:i32=0;
- let mut Eflag:i32=0;
- let mut Iflag:i32=0;
- let mut l:* mut WordList;
- let mut wl:* mut WordList;
- let mut cs:* mut COMPSPEC;
-
- ret = EXECUTION_SUCCESS!();
- unsafe {
- let mut list:* mut WordList=listt.clone();
- reset_internal_getopt ();
-
- opt = internal_getopt (list, CString::new("+o:DEI").unwrap().as_ptr() as * mut c_char);
-
- while opt != -1 {
- if list_opttype == '-' as i32 {
- opts = &mut opts_on;
- } else {
- opts = &mut opts_off;
- }
+pub extern "C" fn r_compopt_builtin(listt: *mut WordList) -> i32 {
+ let mut opts_on: i32 = 0;
+ let mut opts_off: i32 = 0;
+ let mut opts: *mut i32;
+ let mut opt: i32;
+ let mut oind: i32;
+ let mut ret: i32;
+ let mut Dflag: i32 = 0;
+ let mut Eflag: i32 = 0;
+ let mut Iflag: i32 = 0;
+ let mut l: *mut WordList;
+ let mut wl: *mut WordList;
+ let mut cs: *mut COMPSPEC;
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
+ ret = EXECUTION_SUCCESS!();
+ unsafe {
+ let mut list: *mut WordList = listt.clone();
+ reset_internal_getopt();
+
+ opt = internal_getopt(
+ list,
+ CString::new("+o:DEI").unwrap().as_ptr() as *mut c_char,
+ );
+
+ while opt != -1 {
+ if list_opttype == '-' as i32 {
+ opts = &mut opts_on;
+ } else {
+ opts = &mut opts_off;
+ }
- match optChar {
- 'o'=>{
- oind = r_find_compopt (list_optarg);
- if oind < 0 {
- sh_invalidoptname (list_optarg);
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+
+ match optChar {
+ 'o' => {
+ oind = r_find_compopt(list_optarg);
+ if oind < 0 {
+ sh_invalidoptname(list_optarg);
+ return EX_USAGE;
+ }
+ let compopts: CompoptArray = CompoptArray::new();
+ *opts |= compopts.compoptArr[oind as usize].optflag as i32;
+ }
+ 'D' => {
+ Dflag = 1;
+ }
+ 'E' => {
+ Eflag = 1;
+ }
+ 'I' => {
+ Iflag = 1;
+ }
+ _ => {
+ builtin_usage();
return EX_USAGE;
}
- let compopts:CompoptArray=CompoptArray::new();
- *opts |= compopts.compoptArr[oind as usize].optflag as i32;
- }
- 'D'=>{
- Dflag = 1;
}
- 'E'=>{
- Eflag = 1;
- }
- 'I'=>{
- Iflag = 1;
+ opt = internal_getopt(
+ list,
+ CString::new("+o:DEI").unwrap().as_ptr() as *mut c_char,
+ );
+ }
+
+ list = loptend.clone();
+
+ if Dflag != 0 {
+ wl = make_word_list(make_bare_word(DEFAULTCMD()), std::ptr::null_mut());
+ } else if Eflag != 0 {
+ wl = make_word_list(make_bare_word(EMPTYCMD()), std::ptr::null_mut());
+ } else if Iflag != 0 {
+ wl = make_word_list(make_bare_word(INITIALWORD()), std::ptr::null_mut());
+ } else {
+ wl = std::ptr::null_mut();
+ }
+
+ if list == std::ptr::null_mut() && wl == std::ptr::null_mut() {
+ if RL_ISSTATE(RL_STATE_COMPLETING!()) == 0 || pcomp_curcs == std::ptr::null_mut() {
+ builtin_error(
+ CString::new("not currently executing completion function")
+ .unwrap()
+ .as_ptr(),
+ );
+ return EXECUTION_FAILURE!();
}
- _=>{
- builtin_usage ();
- return EX_USAGE;
+ cs = pcomp_curcs.clone();
+
+ if opts_on == 0 && opts_off == 0 {
+ r_print_compopts(pcomp_curcmd, cs, 1);
+ return sh_chkwrite(ret);
}
- }
- opt = internal_getopt (list, CString::new("+o:DEI").unwrap().as_ptr() as * mut c_char);
- }
- list = loptend.clone();
+ /* Set the compspec options */
+ pcomp_set_compspec_options(cs, opts_on, 1);
+ pcomp_set_compspec_options(cs, opts_off, 0);
- if Dflag != 0 {
- wl = make_word_list (make_bare_word (DEFAULTCMD()), std::ptr::null_mut());
- } else if Eflag !=0 {
- wl = make_word_list (make_bare_word (EMPTYCMD()), std::ptr::null_mut());
- } else if Iflag !=0 {
- wl = make_word_list (make_bare_word (INITIALWORD()), std::ptr::null_mut());
- } else {
- wl = std::ptr::null_mut();
- }
+ /* And change the readline variables the options control */
+ pcomp_set_readline_variables(opts_on, 1);
+ pcomp_set_readline_variables(opts_off, 0);
- if list == std::ptr::null_mut() && wl == std::ptr::null_mut() {
- if RL_ISSTATE (RL_STATE_COMPLETING!()) == 0 || pcomp_curcs == std::ptr::null_mut() {
- builtin_error (CString::new("not currently executing completion function").unwrap().as_ptr());
- return EXECUTION_FAILURE!();
+ return ret;
}
- cs = pcomp_curcs.clone();
- if opts_on == 0 && opts_off == 0 {
- r_print_compopts (pcomp_curcmd, cs, 1);
- return sh_chkwrite (ret);
+ if wl != std::ptr::null_mut() {
+ l = wl.clone();
+ } else {
+ l = list.clone();
}
- /* Set the compspec options */
- pcomp_set_compspec_options (cs, opts_on, 1);
- pcomp_set_compspec_options (cs, opts_off, 0);
+ while l != std::ptr::null_mut() {
+ cs = progcomp_search((*((*list).word)).word);
+ if cs == std::ptr::null_mut() {
+ builtin_error(
+ CString::new("%s: no completion specification")
+ .unwrap()
+ .as_ptr(),
+ (*((*list).word)).word,
+ );
+ ret = EXECUTION_FAILURE!();
+ l = (*l).next;
+ continue;
+ }
+ if opts_on == 0 && opts_off == 0 {
+ r_print_compopts((*((*list).word)).word, cs, 1);
+ l = (*l).next;
+ continue; /* XXX -- fill in later */
+ }
- /* And change the readline variables the options control */
- pcomp_set_readline_variables (opts_on, 1);
- pcomp_set_readline_variables (opts_off, 0);
+ /* Set the compspec options */
+ pcomp_set_compspec_options(cs, opts_on, 1);
+ pcomp_set_compspec_options(cs, opts_off, 0);
+ l = (*l).next;
+ }
- return ret;
- }
-
- if wl != std::ptr::null_mut() {
- l = wl.clone();
- } else {
- l=list.clone();
- }
-
- while l != std::ptr::null_mut() {
- cs = progcomp_search ((*((*list).word)).word);
- if cs == std::ptr::null_mut() {
- builtin_error (CString::new("%s: no completion specification").unwrap().as_ptr(), (*((*list).word)).word);
- ret = EXECUTION_FAILURE!();
- l = (*l).next;
- continue;
- }
- if opts_on == 0 && opts_off == 0 {
- r_print_compopts ((*((*list).word)).word, cs, 1);
- l = (*l).next;
- continue; /* XXX -- fill in later */
- }
-
- /* Set the compspec options */
- pcomp_set_compspec_options (cs, opts_on, 1);
- pcomp_set_compspec_options (cs, opts_off, 0);
- l = (*l).next;
+ if wl != std::ptr::null_mut() {
+ dispose_words(wl);
}
- if wl != std::ptr::null_mut() {
- dispose_words (wl);
+ return ret;
}
-
- return ret;
- }
}
-
diff --git a/bash-5.1/builtins_rust/declare/src/lib.rs b/bash-5.1/builtins_rust/declare/src/lib.rs
index cf16162bc5be4cfd8930f0810c5795a8823cc99d..5dc2fbc6acc4bd11797c562831edbc7c3821cd0e 100644
--- a/bash-5.1/builtins_rust/declare/src/lib.rs
+++ b/bash-5.1/builtins_rust/declare/src/lib.rs
@@ -1,1517 +1,1769 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
use libc::{c_char, c_long, c_void};
-use std::{ffi::CString};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, r_savestring};
+use rcommon::{r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
-use rsetattr::{show_name_attributes,set_or_show_attributes,show_all_var_attributes};
+use rsetattr::{set_or_show_attributes, show_all_var_attributes, show_name_attributes};
use std::ffi::CStr;
+use std::ffi::CString;
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub union REDIRECTEE {
- dest:libc::c_int,
- filename:* mut WordDesc
+ dest: libc::c_int,
+ filename: *mut WordDesc,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:REDIRECTEE,
- rflags:libc::c_int,
- flags:libc::c_int,
- instruction:r_instruction,
- redirectee:REDIRECTEE,
- here_doc_eof:*mut c_char
+ next: *mut REDIRECT,
+ redirector: REDIRECTEE,
+ rflags: libc::c_int,
+ flags: libc::c_int,
+ instruction: r_instruction,
+ redirectee: REDIRECTEE,
+ here_doc_eof: *mut c_char,
}
/* FOR command. */
#[repr(C)]
pub struct for_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:libc::c_int
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: libc::c_int,
}
#[repr(C)]
pub struct case_com {
- flags:libc::c_int,
- line:libc::c_int,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ flags: libc::c_int,
+ line: libc::c_int,
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct while_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore:libc::c_int,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector:libc::c_int
+ ignore: libc::c_int,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: libc::c_int,
}
#[repr(C)]
pub struct simple_com {
- flags:libc::c_int,
- line:libc::c_int,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: libc::c_int,
+ line: libc::c_int,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut c_char
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct group_com {
- ignore:libc::c_int,
- command:*mut COMMAND,
- source_file:*mut c_char
+ ignore: libc::c_int,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct select_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct arith_com {
- flags:libc::c_int,
- line:libc::c_int,
- exp:*mut WordList
+ flags: libc::c_int,
+ line: libc::c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct cond_com {
- flags:libc::c_int,
- line:libc::c_int,
- type_c:libc::c_int,
- exp:*mut WordList
+ flags: libc::c_int,
+ line: libc::c_int,
+ type_c: libc::c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct arith_for_com {
- flags:libc::c_int,
- line:libc::c_int,
- init:*mut WordList,
- test:*mut WordList,
- step:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ init: *mut WordList,
+ test: *mut WordList,
+ step: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct subshell_com {
- flags:i32,
- line:i32,
- command:*mut COMMAND
+ flags: i32,
+ line: i32,
+ command: *mut COMMAND,
}
#[repr(C)]
pub struct coproc_com {
- flags:i32,
- name:*mut c_char,
- command:*mut COMMAND
+ flags: i32,
+ name: *mut c_char,
+ command: *mut COMMAND,
}
#[repr(C)]
pub union VALUE_COMMAND {
- For:*mut for_com,
- Case:*mut case_com,
- While:*mut while_com,
- If:*mut if_com,
- Connection:*mut connection,
- Simple:*mut simple_com,
- Function_def:*mut function_def,
- Group:*mut group_com,
- Select:*mut select_com,
- Arith:*mut arith_com,
- Cond:*mut cond_com,
- ArithFor:*mut arith_for_com,
- Subshell:*mut subshell_com,
- Coproc:*mut coproc_com
+ For: *mut for_com,
+ Case: *mut case_com,
+ While: *mut while_com,
+ If: *mut if_com,
+ Connection: *mut connection,
+ Simple: *mut simple_com,
+ Function_def: *mut function_def,
+ Group: *mut group_com,
+ Select: *mut select_com,
+ Arith: *mut arith_com,
+ Cond: *mut cond_com,
+ ArithFor: *mut arith_for_com,
+ Subshell: *mut subshell_com,
+ Coproc: *mut coproc_com,
}
#[repr(C)]
pub struct COMMAND {
- type_c:command_type,
- flags:i32,
- line:i32,
- redirects:*mut REDIRECT,
- value:VALUE_COMMAND
+ type_c: command_type,
+ flags: i32,
+ line: i32,
+ redirects: *mut REDIRECT,
+ value: VALUE_COMMAND,
}
#[repr(C)]
pub struct SHELL_VAR {
- name:*mut c_char, /* Symbol that the user types. */
- value:*mut c_char, /* Value that is returned. */
- exportstr:*mut c_char, /* String for the environment. */
- dynamic_value:*mut fn(v:* mut SHELL_VAR)->*mut SHELL_VAR, /* Function called to return a `dynamic'
- value for a variable, like $SECONDS
- or $RANDOM. */
- assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut c_char,t:c_long,str2:* mut c_char)->*mut SHELL_VAR, /* Function called when this `special
- variable' is assigned a value in
- bind_variable. */
- attributes:i32, /* export, readonly, array, invisible... */
- context:i32 /* Which context this variable belongs to. */
+ name: *mut c_char, /* Symbol that the user types. */
+ value: *mut c_char, /* Value that is returned. */
+ exportstr: *mut c_char, /* String for the environment. */
+ dynamic_value: *mut fn(v: *mut SHELL_VAR) -> *mut SHELL_VAR, /* Function called to return a `dynamic'
+ value for a variable, like $SECONDS
+ or $RANDOM. */
+ assign_func: *mut fn(
+ v: *mut SHELL_VAR,
+ str1: *mut c_char,
+ t: c_long,
+ str2: *mut c_char,
+ ) -> *mut SHELL_VAR, /* Function called when this `special
+ variable' is assigned a value in
+ bind_variable. */
+ attributes: i32, /* export, readonly, array, invisible... */
+ context: i32, /* Which context this variable belongs to. */
}
#[repr(C)]
pub struct BUCKET_CONTENTS {
- next:* mut BUCKET_CONTENTS, /* Link to next hashed key in this bucket. */
- key:* mut c_char, /* What we look up. */
- data:* mut c_void, /* What we really want. */
- khash:u32, /* What key hashes to */
- times_found:i32 /* Number of times this item has been found. */
+ next: *mut BUCKET_CONTENTS, /* Link to next hashed key in this bucket. */
+ key: *mut c_char, /* What we look up. */
+ data: *mut c_void, /* What we really want. */
+ khash: u32, /* What key hashes to */
+ times_found: i32, /* Number of times this item has been found. */
}
#[repr(C)]
pub struct HASH_TABLE {
- bucket_array:*mut * mut BUCKET_CONTENTS, /* Where the data is kept. */
- nbuckets:i32, /* How many buckets does this table have. */
- nentries:i32 /* How many entries does this table have. */
+ bucket_array: *mut *mut BUCKET_CONTENTS, /* Where the data is kept. */
+ nbuckets: i32, /* How many buckets does this table have. */
+ nentries: i32, /* How many entries does this table have. */
}
#[repr(C)]
pub struct VAR_CONTEXT {
- name:* mut c_char,/* empty or NULL means global context */
- scope:i32, /* 0 means global context */
- flags:i32,
- up:* mut VAR_CONTEXT, /* previous function calls */
- down:* mut VAR_CONTEXT, /* down towards global context */
- table:* mut HASH_TABLE /* variables at this scope */
+ name: *mut c_char, /* empty or NULL means global context */
+ scope: i32, /* 0 means global context */
+ flags: i32,
+ up: *mut VAR_CONTEXT, /* previous function calls */
+ down: *mut VAR_CONTEXT, /* down towards global context */
+ table: *mut HASH_TABLE, /* variables at this scope */
}
-
#[macro_export]
macro_rules! ARGS_SETBLTIN {
- () => {
- 0x04
- }
+ () => {
+ 0x04
+ };
}
#[macro_export]
macro_rules! EXITPROG {
- () => {
- 3
- }
+ () => {
+ 3
+ };
}
#[macro_export]
macro_rules! att_local {
- () => {
- 0x0000020
- }
+ () => {
+ 0x0000020
+ };
}
#[macro_export]
macro_rules! att_array {
- () => {
- 0x0000004 /* value is an array */
- }
+ () => {
+ 0x0000004 /* value is an array */
+ };
}
#[macro_export]
macro_rules! att_assoc {
- () => {
- 0x0000040 /* variable is an associative array */
- }
+ () => {
+ 0x0000040 /* variable is an associative array */
+ };
}
#[macro_export]
macro_rules! att_function {
- () => {
- 0x0000008 /* value is a function */
- }
+ () => {
+ 0x0000008 /* value is a function */
+ };
}
#[macro_export]
macro_rules! att_integer {
- () => {
- 0x0000010 /* internal representation is int */
- }
+ () => {
+ 0x0000010 /* internal representation is int */
+ };
}
#[macro_export]
macro_rules! att_nameref {
- () => {
- 0x0000800 /* word is a name reference */
- }
+ () => {
+ 0x0000800 /* word is a name reference */
+ };
}
#[macro_export]
macro_rules! att_readonly {
- () => {
- 0x0000002 /* cannot change */
- }
+ () => {
+ 0x0000002 /* cannot change */
+ };
}
#[macro_export]
macro_rules! att_trace {
- () => {
- 0x0000080 /* function is traced with DEBUG trap */
- }
+ () => {
+ 0x0000080 /* function is traced with DEBUG trap */
+ };
}
#[macro_export]
macro_rules! att_exported {
- () => {
- 0x0000001 /* export to environment */
- }
+ () => {
+ 0x0000001 /* export to environment */
+ };
}
#[macro_export]
macro_rules! att_capcase {
- () => {
- 0x0000400 /* word capitalized on assignment */
- }
+ () => {
+ 0x0000400 /* word capitalized on assignment */
+ };
}
#[macro_export]
macro_rules! att_uppercase {
- () => {
- 0x0000100 /* word converted to uppercase on assignment */
- }
+ () => {
+ 0x0000100 /* word converted to uppercase on assignment */
+ };
}
#[macro_export]
macro_rules! att_lowercase {
- () => {
- 0x0000200 /* word converted to lowercase on assignment */
- }
+ () => {
+ 0x0000200 /* word converted to lowercase on assignment */
+ };
}
#[macro_export]
macro_rules! MKLOC_INHERIT {
- () => {
- 0x04
- }
+ () => {
+ 0x04
+ };
}
-
#[macro_export]
macro_rules! ASS_APPEND {
- () => {
- 0x0001
- }
+ () => {
+ 0x0001
+ };
}
#[macro_export]
macro_rules! ASS_MKLOCAL {
- () => {
- 0x0002
- }
+ () => {
+ 0x0002
+ };
}
#[macro_export]
macro_rules! MKLOC_ARRAYOK {
- () => {
- 0x02
- }
+ () => {
+ 0x02
+ };
}
#[macro_export]
macro_rules! MKLOC_ASSOCOK {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
macro_rules! FUNC_MULTILINE {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
macro_rules! FUNC_EXTERNAL {
- () => {
- 0x02
- }
+ () => {
+ 0x02
+ };
}
#[macro_export]
macro_rules! ASS_FORCE {
- () => {
- 0x0020 /* force assignment even to readonly variable */
- }
+ () => {
+ 0x0020 /* force assignment even to readonly variable */
+ };
}
#[macro_export]
macro_rules! W_COMPASSIGN {
- () => {
- 1 << 15 /* Compound assignment */
- }
+ () => {
+ 1 << 15 /* Compound assignment */
+ };
}
#[macro_export]
macro_rules! ASS_NOEXPAND {
- () => {
- 0x0080 /* don't expand associative array subscripts */
- }
+ () => {
+ 0x0080 /* don't expand associative array subscripts */
+ };
}
#[macro_export]
macro_rules! EX_BADASSIGN {
- () => {
- 260 /* variable assignment error */
- }
+ () => {
+ 260 /* variable assignment error */
+ };
}
#[macro_export]
macro_rules! att_tempvar {
- () => {
- 0x0100000 /* variable came from the temp environment */
- }
+ () => {
+ 0x0100000 /* variable came from the temp environment */
+ };
}
#[macro_export]
macro_rules! att_propagate {
- () => {
- 0x0200000 /* propagate to previous scope */
- }
+ () => {
+ 0x0200000 /* propagate to previous scope */
+ };
}
#[macro_export]
macro_rules! ASS_NAMEREF {
- () => {
- 0x0010 /* assigning to nameref variable */
- }
+ () => {
+ 0x0010 /* assigning to nameref variable */
+ };
}
#[macro_export]
macro_rules! att_invisible {
- () => {
- 0x0001000 /* cannot see */
- }
+ () => {
+ 0x0001000 /* cannot see */
+ };
}
#[macro_export]
macro_rules! att_noassign {
- () => {
- 0x0004000 /* assignment not allowed */
- }
+ () => {
+ 0x0004000 /* assignment not allowed */
+ };
}
pub union Functions {
- f_xfree:unsafe extern "C" fn(str1:* mut c_void),
- f_maybe_pop_dollar_vars: unsafe extern "C" fn(),
- f_maybe_set_debug_trap:unsafe extern "C" fn(* mut c_char)
+ f_xfree: unsafe extern "C" fn(str1: *mut c_void),
+ f_maybe_pop_dollar_vars: unsafe extern "C" fn(),
+ f_maybe_set_debug_trap: unsafe extern "C" fn(*mut c_char),
}
extern "C" {
- static variable_context:i32;
- fn builtin_error(err:*const c_char,...);
- fn builtin_warning(err:*const c_char,...);
- fn find_variable (str:*const c_char)->* mut SHELL_VAR;
- fn find_global_variable (str:*const c_char)->* mut SHELL_VAR;
+ static variable_context: i32;
+ fn builtin_error(err: *const c_char, ...);
+ fn builtin_warning(err: *const c_char, ...);
+ fn find_variable(str: *const c_char) -> *mut SHELL_VAR;
+ fn find_global_variable(str: *const c_char) -> *mut SHELL_VAR;
fn reset_internal_getopt();
- fn internal_getopt (list:*mut WordList , opts:*mut c_char)->i32;
- static mut list_opttype:i32;
- static mut array_needs_making:i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
+ static mut list_opttype: i32;
+ static mut array_needs_making: i32;
fn builtin_usage();
- static mut loptend:*mut WordList;
- fn show_local_var_attributes (v:i32, nodefs:i32)->i32;
+ static mut loptend: *mut WordList;
+ fn show_local_var_attributes(v: i32, nodefs: i32) -> i32;
// fn show_all_var_attributes (v:i32, nodefs:i32)->i32;
- fn set_builtin (list:*mut WordList)->i32;
- fn sh_chkwrite (ret:i32)->i32;
- fn show_func_attributes (name:* mut c_char, nodefs:i32)->i32;
- fn show_localname_attributes (name:* mut c_char, nodefs:i32)->i32;
- fn sh_notfound (name:* mut c_char);
- static assoc_expand_once:i32;
- fn assignment (str1:* const c_char, flags:i32)->i32;
- fn make_local_variable (name:* const c_char, flags:i32)->* mut SHELL_VAR;
- fn get_current_options ()->* mut c_char;
- fn valid_array_reference (name:* const c_char, flags:i32)->i32;
- fn check_selfref (name:* const c_char, value:* mut c_char, flags:i32)->i32;
- fn valid_nameref_value (name:* const c_char, flags:i32)->i32;
- fn sh_invalidid (value:* mut c_char);
- static mut posixly_correct:i32;
- fn nameref_transform_name (name:* mut c_char, flags:i32)->* mut c_char;
- fn find_variable_last_nameref (name:* const c_char, flags:i32)->* mut SHELL_VAR;
- fn make_local_assoc_variable (value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn make_local_array_variable (value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn find_global_variable_last_nameref (value:* const c_char, flags:i32)->* mut SHELL_VAR;
- fn find_global_variable_noref (value:* const c_char)->* mut SHELL_VAR;
- fn find_variable_noref (value:* const c_char)->* mut SHELL_VAR;
- fn sh_readonly (name:* const c_char);
- fn sh_invalidopt (value:* mut c_char);
- static mut debugging_mode:i32;
- fn find_function_def (name:* const c_char)->* mut function_def;
- fn named_function_string (name:* mut c_char, cmd:* mut COMMAND, i:i32)->* mut c_char;
- fn make_new_assoc_variable (name:* mut c_char)->* mut SHELL_VAR;
- fn make_new_array_variable (name:* mut c_char)->* mut SHELL_VAR;
- fn bind_global_variable (name:* const c_char,value:* mut c_char,flags:i32)->* mut SHELL_VAR;
- fn bind_variable (name:* const c_char,value:* mut c_char,flags:i32)->* mut SHELL_VAR;
- static mut shell_compatibility_level:i32;
- fn internal_warning (format:* const c_char, ...);
- fn assign_array_element (name:* mut c_char, value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn bind_assoc_variable (var:* mut SHELL_VAR, name:* mut c_char, key:* mut c_char, value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn bind_array_variable (name:* mut c_char, s:libc::c_long, value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn bind_variable_value (var:* mut SHELL_VAR, name:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn delete_var (name:* const c_char, varc:* mut VAR_CONTEXT)->i32;
- static global_variables:* mut VAR_CONTEXT;
- static shell_variables:* mut VAR_CONTEXT;
- fn find_tempenv_variable (format:* const c_char)->* mut SHELL_VAR;
- fn stupidly_hack_special_variables (name:* mut c_char);
- fn assign_array_var_from_string (var:* mut SHELL_VAR, value:* mut c_char, flags:i32)->* mut SHELL_VAR;
- fn convert_var_to_array (var:* mut SHELL_VAR)->* mut SHELL_VAR;
- fn convert_var_to_assoc (var:* mut SHELL_VAR)->* mut SHELL_VAR;
- fn find_function (name:* const c_char)->* mut SHELL_VAR;
- fn legal_identifier (name:* const c_char)->i32;
+ fn set_builtin(list: *mut WordList) -> i32;
+ fn sh_chkwrite(ret: i32) -> i32;
+ fn show_func_attributes(name: *mut c_char, nodefs: i32) -> i32;
+ fn show_localname_attributes(name: *mut c_char, nodefs: i32) -> i32;
+ fn sh_notfound(name: *mut c_char);
+ static assoc_expand_once: i32;
+ fn assignment(str1: *const c_char, flags: i32) -> i32;
+ fn make_local_variable(name: *const c_char, flags: i32) -> *mut SHELL_VAR;
+ fn get_current_options() -> *mut c_char;
+ fn valid_array_reference(name: *const c_char, flags: i32) -> i32;
+ fn check_selfref(name: *const c_char, value: *mut c_char, flags: i32) -> i32;
+ fn valid_nameref_value(name: *const c_char, flags: i32) -> i32;
+ fn sh_invalidid(value: *mut c_char);
+ static mut posixly_correct: i32;
+ fn nameref_transform_name(name: *mut c_char, flags: i32) -> *mut c_char;
+ fn find_variable_last_nameref(name: *const c_char, flags: i32) -> *mut SHELL_VAR;
+ fn make_local_assoc_variable(value: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ fn make_local_array_variable(value: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ fn find_global_variable_last_nameref(value: *const c_char, flags: i32) -> *mut SHELL_VAR;
+ fn find_global_variable_noref(value: *const c_char) -> *mut SHELL_VAR;
+ fn find_variable_noref(value: *const c_char) -> *mut SHELL_VAR;
+ fn sh_readonly(name: *const c_char);
+ fn sh_invalidopt(value: *mut c_char);
+ static mut debugging_mode: i32;
+ fn find_function_def(name: *const c_char) -> *mut function_def;
+ fn named_function_string(name: *mut c_char, cmd: *mut COMMAND, i: i32) -> *mut c_char;
+ fn make_new_assoc_variable(name: *mut c_char) -> *mut SHELL_VAR;
+ fn make_new_array_variable(name: *mut c_char) -> *mut SHELL_VAR;
+ fn bind_global_variable(name: *const c_char, value: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ fn bind_variable(name: *const c_char, value: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ static mut shell_compatibility_level: i32;
+ fn internal_warning(format: *const c_char, ...);
+ fn assign_array_element(name: *mut c_char, value: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ fn bind_assoc_variable(
+ var: *mut SHELL_VAR,
+ name: *mut c_char,
+ key: *mut c_char,
+ value: *mut c_char,
+ flags: i32,
+ ) -> *mut SHELL_VAR;
+ fn bind_array_variable(
+ name: *mut c_char,
+ s: libc::c_long,
+ value: *mut c_char,
+ flags: i32,
+ ) -> *mut SHELL_VAR;
+ fn bind_variable_value(var: *mut SHELL_VAR, name: *mut c_char, flags: i32) -> *mut SHELL_VAR;
+ fn delete_var(name: *const c_char, varc: *mut VAR_CONTEXT) -> i32;
+ static global_variables: *mut VAR_CONTEXT;
+ static shell_variables: *mut VAR_CONTEXT;
+ fn find_tempenv_variable(format: *const c_char) -> *mut SHELL_VAR;
+ fn stupidly_hack_special_variables(name: *mut c_char);
+ fn assign_array_var_from_string(
+ var: *mut SHELL_VAR,
+ value: *mut c_char,
+ flags: i32,
+ ) -> *mut SHELL_VAR;
+ fn convert_var_to_array(var: *mut SHELL_VAR) -> *mut SHELL_VAR;
+ fn convert_var_to_assoc(var: *mut SHELL_VAR) -> *mut SHELL_VAR;
+ fn find_function(name: *const c_char) -> *mut SHELL_VAR;
+ fn legal_identifier(name: *const c_char) -> i32;
}
#[no_mangle]
-pub extern "C" fn r_declare_builtin (list:* mut WordList)->i32
-{
- return r_declare_internal (list, 0);
+pub extern "C" fn r_declare_builtin(list: *mut WordList) -> i32 {
+ return r_declare_internal(list, 0);
}
-unsafe fn STREQ( a:* const c_char, b:* const c_char)->bool {
- return *a ==*b && libc::strcmp(a, b) == 0;
+unsafe fn STREQ(a: *const c_char, b: *const c_char) -> bool {
+ return *a == *b && libc::strcmp(a, b) == 0;
}
#[no_mangle]
-pub extern "C" fn r_local_builtin (list:* mut WordList)->i32
-{
- unsafe {
- /* Catch a straight `local --help' before checking function context */
- if list !=std::ptr::null_mut() && (*list).word != std::ptr::null_mut() && STREQ ((*(*list).word).word, CString::new("--help").unwrap().as_ptr()) {
- r_builtin_help ();
- return EX_USAGE;
- }
-
- if variable_context !=0 {
- return r_declare_internal (list, 1);
- } else {
- builtin_error (CString::new("can only be used in a function").unwrap().as_ptr());
- return EXECUTION_FAILURE!();
- }
- }
+pub extern "C" fn r_local_builtin(list: *mut WordList) -> i32 {
+ unsafe {
+ /* Catch a straight `local --help' before checking function context */
+ if list != std::ptr::null_mut()
+ && (*list).word != std::ptr::null_mut()
+ && STREQ(
+ (*(*list).word).word,
+ CString::new("--help").unwrap().as_ptr(),
+ )
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ if variable_context != 0 {
+ return r_declare_internal(list, 1);
+ } else {
+ builtin_error(
+ CString::new("can only be used in a function")
+ .unwrap()
+ .as_ptr()
+ );
+ return EXECUTION_FAILURE!();
+ }
+ }
}
-unsafe fn local_p( varr:* mut SHELL_VAR)->i32 {
- return (*varr).attributes & att_local!();
+unsafe fn local_p(varr: *mut SHELL_VAR) -> i32 {
+ return (*varr).attributes & att_local!();
}
#[no_mangle]
-pub extern "C" fn r_declare_find_variable (name:* const c_char, mkglobal:i32, chklocal:i32)->* mut SHELL_VAR
-{
- let varr: * mut SHELL_VAR;
- unsafe {
- if mkglobal == 0 {
- return find_variable (name);
- } else if chklocal !=0 {
- varr = find_variable (name);
- if varr != std::ptr::null_mut() && local_p (varr) !=0 && (*varr).context == variable_context {
- return varr;
- }
-
- return find_global_variable (name);
- } else {
- return find_global_variable (name);
+pub extern "C" fn r_declare_find_variable(
+ name: *const c_char,
+ mkglobal: i32,
+ chklocal: i32,
+) -> *mut SHELL_VAR {
+ let varr: *mut SHELL_VAR;
+ unsafe {
+ if mkglobal == 0 {
+ return find_variable(name);
+ } else if chklocal != 0 {
+ varr = find_variable(name);
+ if varr != std::ptr::null_mut()
+ && local_p(varr) != 0
+ && (*varr).context == variable_context
+ {
+ return varr;
+ }
+
+ return find_global_variable(name);
+ } else {
+ return find_global_variable(name);
+ }
}
- }
}
-unsafe fn DECLARE_OPTS()-> CString
-{
- return CString::new("+acfgilnprtuxAFGI").unwrap();
+unsafe fn DECLARE_OPTS() -> CString {
+ return CString::new("+acfgilnprtuxAFGI").unwrap();
}
-unsafe fn value_cell(var:*mut SHELL_VAR)->* mut c_char
-{
- return (*var).value;
+unsafe fn value_cell(var: *mut SHELL_VAR) -> *mut c_char {
+ return (*var).value;
}
-unsafe fn var_setvalue(var:*mut SHELL_VAR,str1:* mut c_char)
-{
- (*var).value=str1;
+unsafe fn var_setvalue(var: *mut SHELL_VAR, str1: *mut c_char) {
+ (*var).value = str1;
}
-unsafe fn VSETATTR(var:*mut SHELL_VAR, attr:i32) {
- (*var).attributes |= attr;
+unsafe fn VSETATTR(var: *mut SHELL_VAR, attr: i32) {
+ (*var).attributes |= attr;
}
-unsafe fn readonly_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_readonly!();
+unsafe fn readonly_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_readonly!();
}
-unsafe fn nameref_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_nameref!();
+unsafe fn nameref_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_nameref!();
}
-unsafe fn nameref_cell(var:*mut SHELL_VAR) ->* mut c_char {
- return (*var).value;/* so it can change later */
+unsafe fn nameref_cell(var: *mut SHELL_VAR) -> *mut c_char {
+ return (*var).value; /* so it can change later */
}
-unsafe fn function_cell(var:*mut SHELL_VAR) ->* mut COMMAND {
- return (*var).value as * mut COMMAND;
+unsafe fn function_cell(var: *mut SHELL_VAR) -> *mut COMMAND {
+ return (*var).value as *mut COMMAND;
}
-unsafe fn VUNSETATTR(var:*mut SHELL_VAR,attr:i32) {
- (*var).attributes &= !attr;
+unsafe fn VUNSETATTR(var: *mut SHELL_VAR, attr: i32) {
+ (*var).attributes &= !attr;
}
-unsafe fn array_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_array!();
+unsafe fn array_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_array!();
}
-unsafe fn assoc_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_assoc!();
+unsafe fn assoc_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_assoc!();
}
-unsafe fn var_isset(var:*mut SHELL_VAR) ->bool {
- return (*var).value !=std::ptr::null_mut();
+unsafe fn var_isset(var: *mut SHELL_VAR) -> bool {
+ return (*var).value != std::ptr::null_mut();
}
-unsafe fn tempvar_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_tempvar!();
+unsafe fn tempvar_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_tempvar!();
}
-unsafe fn noassign_p(var:*mut SHELL_VAR) ->i32 {
- return (*var).attributes & att_noassign!();
+unsafe fn noassign_p(var: *mut SHELL_VAR) -> i32 {
+ return (*var).attributes & att_noassign!();
}
#[no_mangle]
-pub extern "C" fn r_declare_internal (mut list:* mut WordList, local_var:i32)->i32
-{
- let mut flags_on:i32=0;
- let mut flags_off:i32=0;
- let mut flags:* mut i32;
- let mut any_failed:i32=0;
- let mut assign_error:i32=0;
- let mut pflag:i32=0;
- let mut nodefs:i32=0;
- let mut opt:i32;
- let mut onref:i32;
- let mut offref:i32;
- let mut mkglobal:i32=0;
- let mut chklocal:i32=0;
- let mut inherit_flag:i32=0;
-
- let mut t: *mut c_char;
- let mut subscript_start: *mut c_char;
- let mut var:*mut SHELL_VAR;
- let mut refvar:*mut SHELL_VAR;
- let mut v:*mut SHELL_VAR;
-
- let mut shell_fn:*mut function_def;
-
- refvar = std::ptr::null_mut();
- unsafe {
- reset_internal_getopt ();
- let tmp = DECLARE_OPTS();
- opt = internal_getopt (list, tmp.as_ptr() as * mut c_char);
- while opt != -1 {
- if list_opttype == '+' as i32 {
- flags= &mut flags_off;
- } else {
- flags= &mut flags_on;
- }
-
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
-
- /* If you add options here, see whether or not they need to be added to
- the loop in subst.c:shell_expand_word_list() */
- match optChar {
- 'a'=>{ *flags |= att_array!();}
- 'A'=>{ *flags |= att_assoc!();}
- 'p'=>{ pflag+=1;}
- 'F'=>{ nodefs+=1;
- *flags |= att_function!();
- }
- 'f'=>{ *flags |= att_function!();}
- 'G'=>{
- if flags == &mut flags_on {
- chklocal = 1;
- }
- }
- 'g'=>{
- if flags == &mut flags_on {
- mkglobal = 1;
- }
+pub extern "C" fn r_declare_internal(mut list: *mut WordList, local_var: i32) -> i32 {
+ let mut flags_on: i32 = 0;
+ let mut flags_off: i32 = 0;
+ let mut flags: *mut i32;
+ let mut any_failed: i32 = 0;
+ let mut assign_error: i32 = 0;
+ let mut pflag: i32 = 0;
+ let mut nodefs: i32 = 0;
+ let mut opt: i32;
+ let mut onref: i32;
+ let mut offref: i32;
+ let mut mkglobal: i32 = 0;
+ let mut chklocal: i32 = 0;
+ let mut inherit_flag: i32 = 0;
+
+ let mut t: *mut c_char;
+ let mut subscript_start: *mut c_char;
+ let mut var: *mut SHELL_VAR;
+ let mut refvar: *mut SHELL_VAR;
+ let mut v: *mut SHELL_VAR;
+
+ let mut shell_fn: *mut function_def;
+
+ refvar = std::ptr::null_mut();
+ unsafe {
+ reset_internal_getopt();
+ let tmp = DECLARE_OPTS();
+ opt = internal_getopt(list, tmp.as_ptr() as *mut c_char);
+ while opt != -1 {
+ if list_opttype == '+' as i32 {
+ flags = &mut flags_off;
+ } else {
+ flags = &mut flags_on;
+ }
+
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+
+ /* If you add options here, see whether or not they need to be added to
+ the loop in subst.c:shell_expand_word_list() */
+ match optChar {
+ 'a' => {
+ *flags |= att_array!();
+ }
+ 'A' => {
+ *flags |= att_assoc!();
+ }
+ 'p' => {
+ pflag += 1;
+ }
+ 'F' => {
+ nodefs += 1;
+ *flags |= att_function!();
+ }
+ 'f' => {
+ *flags |= att_function!();
+ }
+ 'G' => {
+ if flags == &mut flags_on {
+ chklocal = 1;
+ }
+ }
+ 'g' => {
+ if flags == &mut flags_on {
+ mkglobal = 1;
+ }
+ }
+ 'i' => {
+ *flags |= att_integer!();
+ }
+ 'n' => {
+ *flags |= att_nameref!();
+ }
+ 'r' => {
+ *flags |= att_readonly!();
+ }
+ 't' => {
+ *flags |= att_trace!();
+ }
+ 'x' => {
+ *flags |= att_exported!();
+ array_needs_making = 1;
+ }
+ 'c' => {
+ *flags |= att_capcase!();
+ if flags == &mut flags_on {
+ flags_off |= att_uppercase!() | att_lowercase!();
+ }
+ }
+ 'l' => {
+ *flags |= att_lowercase!();
+ if flags == &mut flags_on {
+ flags_off |= att_capcase!() | att_uppercase!();
+ }
+ }
+ 'u' => {
+ *flags |= att_uppercase!();
+ if flags == &mut flags_on {
+ flags_off |= att_capcase!() | att_lowercase!();
+ }
+ }
+ 'I' => {
+ inherit_flag = MKLOC_INHERIT!();
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ opt = internal_getopt(list, tmp.as_ptr() as *mut c_char);
}
- 'i'=>{ *flags |= att_integer!();}
- 'n'=>{ *flags |= att_nameref!();}
- 'r'=>{ *flags |= att_readonly!();}
- 't'=>{ *flags |= att_trace!();}
- 'x'=>{ *flags |= att_exported!();
- array_needs_making = 1;
- }
- 'c'=>{ *flags |= att_capcase!();
- if flags == &mut flags_on {
- flags_off |= att_uppercase!() | att_lowercase!();
- }
- }
- 'l'=>{ *flags |= att_lowercase!();
- if flags == &mut flags_on {
- flags_off |= att_capcase!()| att_uppercase!();
- }
- }
- 'u'=>{ *flags |= att_uppercase!();
- if flags == &mut flags_on {
- flags_off |= att_capcase!()| att_lowercase!();
- }
- }
- 'I'=>{ inherit_flag = MKLOC_INHERIT!();}
- _=>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
- }
- builtin_usage ();
- return EX_USAGE;
+ list = loptend;
+ /* If there are no more arguments left, then we just want to show
+ some variables. */
+ if list == std::ptr::null_mut() {
+ /* declare -[aAfFirtx] */
+ /* Show local variables defined at this context level if this is
+ the `local' builtin. */
+ if local_var != 0 {
+ show_local_var_attributes(0, nodefs); /* XXX - fix up args later */
+ } else if pflag != 0 && (flags_on == 0 || flags_on == att_function!()) {
+ let mut ret = 0;
+ if flags_on == 0 {
+ ret = 1;
+ }
+ show_all_var_attributes(ret, nodefs);
+ } else if flags_on == 0 {
+ return set_builtin(std::ptr::null_mut());
+ } else {
+ set_or_show_attributes(std::ptr::null_mut(), flags_on, nodefs);
}
- }
- opt = internal_getopt (list, tmp.as_ptr() as * mut c_char);
- }
- list = loptend;
- /* If there are no more arguments left, then we just want to show
- some variables. */
- if list == std::ptr::null_mut() { /* declare -[aAfFirtx] */
- /* Show local variables defined at this context level if this is
- the `local' builtin. */
- if local_var != 0 {
- show_local_var_attributes (0, nodefs); /* XXX - fix up args later */
- } else if pflag != 0 && (flags_on == 0 || flags_on == att_function!()) {
- let mut ret=0;
- if flags_on == 0 {
- ret=1;
+ return sh_chkwrite(EXECUTION_SUCCESS!());
}
- show_all_var_attributes (ret, nodefs);
- } else if flags_on == 0 {
- return set_builtin (std::ptr::null_mut());
- } else {
- set_or_show_attributes (std::ptr::null_mut(), flags_on, nodefs);
- }
- return sh_chkwrite (EXECUTION_SUCCESS!());
- }
-
- if pflag !=0 { /* declare -p [-aAfFirtx] name [name...] */
- any_failed=0;
- while list != std::ptr::null_mut() {
- if (flags_on & att_function!()) != 0 {
- pflag = show_func_attributes ((*(*list).word).word, nodefs);
- } else if local_var !=0 {
- pflag = show_localname_attributes ((*(*list).word).word, nodefs);
- } else {
- pflag = show_name_attributes ((*(*list).word).word, nodefs);
+
+ if pflag != 0 {
+ /* declare -p [-aAfFirtx] name [name...] */
+ any_failed = 0;
+ while list != std::ptr::null_mut() {
+ if (flags_on & att_function!()) != 0 {
+ pflag = show_func_attributes((*(*list).word).word, nodefs);
+ } else if local_var != 0 {
+ pflag = show_localname_attributes((*(*list).word).word, nodefs);
+ } else {
+ pflag = show_name_attributes((*(*list).word).word, nodefs);
+ }
+ if pflag != 0 {
+ sh_notfound((*(*list).word).word);
+ any_failed += 1;
+ }
+ list = (*list).next;
+ }
+
+ if any_failed != 0 {
+ return EXECUTION_FAILURE!();
+ } else {
+ return EXECUTION_SUCCESS!();
+ }
}
- if pflag !=0 {
- sh_notfound ((*(*list).word).word);
- any_failed += 1;
+ let tmpValue = CString::new("").unwrap();
+
+ /* There are arguments left, so we are making variables. */
+ 'outter: while list != std::ptr::null_mut() {
+ /* declare [-aAfFirx] name [name ...] */
+ let mut value: *mut c_char;
+ let mut name: *mut c_char;
+ let mut oldname: *mut c_char;
+ let mut offset: i32;
+ let mut aflags: i32;
+ let wflags: i32;
+ let mut created_var: i32;
+ let mut namelen: i32;
+ let assoc_noexpand: bool;
+
+ let mut making_array_special: i32;
+ let mut compound_array_assign: i32;
+ let mut simple_array_assign: i32;
+ let mut var_exists: i32;
+ let mut array_exists: i32;
+ let mut creating_array: i32;
+ let mut array_subscript_assignment: bool;
+
+ name = r_savestring((*(*list).word).word);
+ wflags = (*(*list).word).flags;
+
+ assoc_noexpand = assoc_expand_once != 0 && (wflags & (1 << 2)) != 0;
+ // 分出=
+ if assoc_noexpand {
+ offset = assignment(name, 2);
+ } else {
+ offset = assignment(name, 0);
+ }
+
+ aflags = 0;
+ created_var = 0;
+
+ if local_var != 0
+ && variable_context != 0
+ && STREQ(name, CString::new("-").unwrap().as_ptr())
+ {
+ var = make_local_variable(CString::new("-").unwrap().as_ptr(), 0);
+ if value_cell(var) != std::ptr::null_mut() {
+ libc::free(value_cell(var) as *mut c_void); /* just in case */
+ }
+ value = get_current_options();
+ var_setvalue(var, value);
+ VSETATTR(var, att_invisible!());
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if offset != 0 {
+ /* declare [-aAfFirx] name=value */
+ *name.offset(offset as isize) = '\0' as c_char;
+ value = name.offset((offset + 1) as isize);
+ if *(name.offset((offset - 1) as isize)) == '+' as c_char {
+ aflags |= ASS_APPEND!();
+ *(name.offset((offset - 1) as isize)) = '\0' as c_char;
+ }
+ } else {
+ value = tmpValue.as_ptr() as *mut c_char;
+ }
+ /* Do some lexical error checking on the LHS and RHS of the assignment
+ that is specific to nameref variables. */
+ if (flags_on & att_nameref!()) != 0 {
+ if valid_array_reference(name, 0) != 0 {
+ builtin_error(
+ CString::new("%s: reference variable cannot be an array")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ } else if check_selfref(name, value, 0) != 0 {
+ /* disallow self references at global scope, warn at function scope */
+ if variable_context == 0 {
+ builtin_error(
+ CString::new("%s: nameref variable self references not allowed")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ } else {
+ builtin_warning(
+ CString::new("%s: circular name reference")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ }
+ }
+
+ if value != std::ptr::null_mut()
+ && (*value) != 0
+ && (aflags & ASS_APPEND!()) == 0
+ && valid_nameref_value(value, 1) == 0
+ {
+ builtin_error(
+ CString::new("`nvalid %s': ivariable name for name reference")
+ .unwrap()
+ .as_ptr(),
+ value,
+ );
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ }
+ //restart_new_var_name:
+ 'inner: loop {
+ var_exists = 0;
+ array_exists = 0;
+ creating_array = 0;
+ compound_array_assign = 0;
+ simple_array_assign = 0;
+ array_subscript_assignment = false;
+ subscript_start = std::ptr::null_mut();
+ t = libc::strchr(name, '[' as libc::c_int);
+ if t != std::ptr::null_mut() && (flags_on & att_function!()) == 0 {
+ /* ] */
+ /* If offset != 0 we have already validated any array reference
+ because assignment() calls skipsubscript() */
+ if offset == 0 && valid_array_reference(name, 0) == 0 {
+ sh_invalidid(name);
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ subscript_start = t;
+ *t = '\0' as c_char;
+ making_array_special = 1; /* XXX - should this check offset? */
+ array_subscript_assignment = offset != 0;
+ } else {
+ making_array_special = 0;
+ }
+ /* If we're in posix mode or not looking for a shell function (since
+ shell function names don't have to be valid identifiers when the
+ shell's not in posix mode), check whether or not the argument is a
+ valid, well-formed shell identifier. */
+ if (posixly_correct != 0 || (flags_on & att_function!()) == 0)
+ && legal_identifier(name) == 0
+ {
+ sh_invalidid(name);
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ /* If VARIABLE_CONTEXT has a non-zero value, then we are executing
+ inside of a function. This means we should make local variables,
+ not global ones. */
+
+ /* XXX - this has consequences when we're making a local copy of a
+ variable that was in the temporary environment. Watch out
+ for this. */
+ refvar = std::ptr::null_mut();
+ if variable_context != 0 && mkglobal == 0 && ((flags_on & att_function!()) == 0) {
+ let newname: *mut c_char;
+
+ /* check name for validity here? */
+ var = find_variable(name);
+ if var == std::ptr::null_mut() {
+ newname = nameref_transform_name(name, ASS_MKLOCAL!());
+ } else if (flags_on & att_nameref!()) == 0 && (flags_off & att_nameref!()) == 0
+ {
+ /* Ok, we're following namerefs here, so let's make sure that if
+ we followed one, it was at the same context (see below for
+ more details). */
+ refvar = find_variable_last_nameref(name, 1);
+ if refvar != std::ptr::null_mut() && (*refvar).context != variable_context {
+ newname = name;
+ } else {
+ newname = (*var).name;
+ }
+ refvar = std::ptr::null_mut();
+ } else {
+ newname = name; /* dealing with nameref attribute */
+ }
+ // 至此,find_variable 返回var 没有被更新
+ /* Pass 1 as second argument to make_local_{assoc,array}_variable
+ return an existing {array,assoc} variable to be flagged as an
+ error below. */
+ if (flags_on & att_assoc!()) != 0 {
+ var = make_local_assoc_variable(newname, MKLOC_ARRAYOK!() | inherit_flag);
+ } else if (flags_on & att_array!()) != 0 || making_array_special != 0 {
+ var = make_local_array_variable(newname, MKLOC_ASSOCOK!() | inherit_flag);
+ } else if offset == 0 && (flags_on & att_nameref!()) != 0 {
+ /* First look for refvar at current scope */
+ refvar = find_variable_last_nameref(name, 1);
+ /* VARIABLE_CONTEXT != 0, so we are attempting to create or modify
+ the attributes for a local variable at the same scope. If we've
+ used a reference from a previous context to resolve VAR, we
+ want to throw REFVAR and VAR away and create a new local var. */
+ if refvar != std::ptr::null_mut() && (*refvar).context != variable_context {
+ refvar = std::ptr::null_mut();
+ var = make_local_variable(name, inherit_flag);
+ } else if refvar != std::ptr::null_mut()
+ && (*refvar).context == variable_context
+ {
+ var = refvar;
+ } else if var == std::ptr::null_mut()
+ || (*refvar).context != variable_context
+ {
+ /* Maybe we just want to create a new local variable */
+ var = make_local_variable(name, inherit_flag);
+ }
+ /* otherwise we have a var at the right context */
+ } else {
+ /* XXX - check name for validity here with valid_nameref_value */
+ if flags_on & att_nameref!() != 0 {
+ var = make_local_variable(name, inherit_flag);
+ } else {
+ var = make_local_variable(newname, inherit_flag); /* sets att_invisible for new vars */
+ }
+ }
+
+ if var == std::ptr::null_mut() {
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if var != std::ptr::null_mut()
+ && nameref_p(var) != 0
+ && readonly_p(var) != 0
+ && nameref_cell(var) != std::ptr::null_mut()
+ && (flags_off & att_nameref!()) != 0
+ {
+ sh_readonly(name);
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ } else {
+ var = std::ptr::null_mut();
+ }
+ /* If we are declaring a function, then complain about it in some way.
+ We don't let people make functions by saying `typeset -f foo=bar'. */
+
+ /* There should be a way, however, to let people look at a particular
+ function definition by saying `typeset -f foo'. */
+
+ if (flags_on & att_function!()) != 0 {
+ if offset != 0 {
+ /* declare -f [-rix] foo=bar */
+ builtin_error(
+ CString::new("cannot use `-f' to make functions")
+ .unwrap()
+ .as_ptr(),
+ );
+ libc::free(name as *mut c_void);
+ return EXECUTION_FAILURE!();
+ } else {
+ /* declare -f [-rx] name [name...] */
+ var = find_function(name);
+ if var != std::ptr::null_mut() {
+ if readonly_p(var) != 0 && (flags_off & att_readonly!()) != 0 {
+ builtin_error(
+ CString::new("%s: readonly function").unwrap().as_ptr(),
+ name,
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ } else if (flags_on & (att_array!() | att_assoc!())) != 0 {
+ if (flags_on & att_array!()) != 0 {
+ sh_invalidopt(
+ CString::new("-a").unwrap().as_ptr() as *mut c_char
+ );
+ } else {
+ sh_invalidopt(
+ CString::new("-A").unwrap().as_ptr() as *mut c_char
+ );
+ }
+
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ /* declare -[Ff] name [name...] */
+ if flags_on == att_function!() && flags_off == 0 {
+ if nodefs != 0 && debugging_mode != 0 {
+ shell_fn = find_function_def((*var).name);
+ if shell_fn != std::ptr::null_mut() {
+ println!(
+ "{} {} {}",
+ CStr::from_ptr((*var).name).to_str().unwrap(),
+ (*shell_fn).line,
+ CStr::from_ptr((*shell_fn).source_file)
+ .to_str()
+ .unwrap()
+ );
+ } else {
+ println!(
+ "{}",
+ CStr::from_ptr((*var).name).to_str().unwrap()
+ );
+ }
+ } else {
+ if nodefs != 0 {
+ t = (*var).name;
+ } else {
+ t = named_function_string(
+ name,
+ function_cell(var),
+ FUNC_MULTILINE!() | FUNC_EXTERNAL!(),
+ );
+ }
+ println!("{}", CStr::from_ptr(t).to_str().unwrap());
+ any_failed = sh_chkwrite(any_failed);
+ }
+ } else {
+ /* declare -[fF] -[rx] name [name...] */
+ VSETATTR(var, flags_on);
+ flags_off &= !att_function!(); /* makes no sense */
+ VUNSETATTR(var, flags_off);
+ }
+ } else {
+ any_failed += 1;
+ }
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ } else {
+ /* declare -[aAinrx] name [name...] */
+ /* Non-null if we just created or fetched a local variable. */
+
+ /* Here's what ksh93 seems to do as of the 2012 version: if we are
+ using declare -n to modify the value of an existing nameref
+ variable, don't follow the nameref chain at all and just search
+ for a nameref at the current context. If we have a nameref,
+ modify its value (changing which variable #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */it references). */
+ if var == std::ptr::null_mut() && (flags_on & att_nameref!()) != 0 {
+ /* See if we are trying to modify an existing nameref variable,
+ but don't follow the nameref chain. */
+ if mkglobal != 0 {
+ var = find_global_variable_noref(name);
+ } else {
+ var = find_variable_noref(name);
+ }
+
+ if var != std::ptr::null_mut() && nameref_p(var) == 0 {
+ var = std::ptr::null_mut();
+ }
+ } else if var == std::ptr::null_mut() && (flags_off & att_nameref!()) != 0 {
+ /* However, if we're turning off the nameref attribute on an existing
+ nameref variable, we first follow the nameref chain to the end,
+ modify the value of the variable this nameref variable references
+ if there is an assignment statement argument,
+ *CHANGING ITS VALUE AS A SIDE EFFECT*, then turn off the nameref
+ flag *LEAVING THE NAMEREF VARIABLE'S VALUE UNCHANGED* */
+ /* See if we are trying to modify an existing nameref variable */
+ if mkglobal != 0 {
+ refvar = find_global_variable_last_nameref(name, 0);
+ } else {
+ refvar = find_variable_last_nameref(name, 0);
+ }
+
+ if refvar != std::ptr::null_mut() && nameref_p(refvar) == 0 {
+ refvar = std::ptr::null_mut();
+ }
+ /* If the nameref is readonly but doesn't have a value, ksh93
+ allows the nameref attribute to be removed. If it's readonly
+ and has a value, even if the value doesn't reference an
+ existing variable, we disallow the modification */
+ if refvar != std::ptr::null_mut()
+ && nameref_cell(refvar) != std::ptr::null_mut()
+ && readonly_p(refvar) != 0
+ {
+ sh_readonly(name);
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ /* If all we're doing is turning off the nameref attribute, don't
+ bother with VAR at all, whether it exists or not. Just turn it
+ off and go on. */
+ if refvar != std::ptr::null_mut()
+ && flags_on == 0
+ && offset == 0
+ && (flags_off & !att_nameref!()) == 0
+ {
+ VUNSETATTR(refvar, att_nameref!());
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if refvar != std::ptr::null_mut() {
+ /* XXX - use declare_find_variable here? */
+ if mkglobal != 0 {
+ var = find_global_variable(nameref_cell(refvar));
+ } else {
+ var = find_variable(nameref_cell(refvar));
+ }
+ }
+ } else if var == std::ptr::null_mut()
+ && offset != 0
+ && array_subscript_assignment
+ {
+ /* If we have an array assignment to a nameref, remove the nameref
+ attribute and go on. */
+ if mkglobal != 0 {
+ var = find_global_variable_noref(name);
+ } else {
+ var = find_variable_noref(name);
+ }
+
+ if var != std::ptr::null_mut() && nameref_p(var) != 0 {
+ internal_warning(
+ CString::new("%s: removing nameref attribute")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ libc::free(value_cell(var) as *mut c_void); /* XXX - bash-4.3 compat */
+ var_setvalue(var, std::ptr::null_mut());
+ VUNSETATTR(var, att_nameref!());
+ }
+ }
+
+ /* See if we are trying to set flags or value (or create) for an
+ existing nameref that points to a non-existent variable: e.g.,
+ declare -n foo=bar
+ unset foo # unsets bar
+ declare -i foo
+ foo=4+4
+ declare -p foo */
+ if var == std::ptr::null_mut()
+ && (mkglobal != 0 || flags_on != 0 || flags_off != 0 || offset != 0)
+ {
+ if mkglobal != 0 {
+ refvar = find_global_variable_last_nameref(name, 0);
+ } else {
+ refvar = find_variable_last_nameref(name, 0);
+ }
+
+ if refvar != std::ptr::null_mut() && nameref_p(refvar) == 0 {
+ refvar = std::ptr::null_mut();
+ }
+
+ if refvar != std::ptr::null_mut() {
+ /* XXX - use declare_find_variable here? */
+ if mkglobal != 0 {
+ var = find_global_variable(nameref_cell(refvar));
+ } else {
+ var = find_variable(nameref_cell(refvar));
+ }
+ }
+
+ if refvar != std::ptr::null_mut() && var == std::ptr::null_mut() {
+ oldname = name; /* need to free this */
+ namelen = libc::strlen(nameref_cell(refvar)) as i32;
+
+ if subscript_start != std::ptr::null_mut() {
+ *subscript_start = '[' as c_char; /*]*/
+ namelen += libc::strlen(subscript_start) as i32;
+ }
+
+ name =
+ libc::malloc(namelen as libc::size_t + 2 + libc::strlen(value) + 1)
+ as *mut c_char;
+ libc::strcpy(name, nameref_cell(refvar));
+
+ if subscript_start != std::ptr::null_mut() {
+ libc::strcpy(
+ name.offset(libc::strlen(nameref_cell(refvar)) as isize),
+ subscript_start,
+ );
+ }
+
+ /* We are committed to using the new name, so reset */
+ if offset != 0 {
+ /* Rebuild assignment and restore offset and value */
+ if (aflags & ASS_APPEND!()) != 0 {
+ *(name.offset(namelen as isize) as *mut c_char) = '+' as c_char;
+
+ namelen += 1;
+ }
+ *(name.offset(namelen as isize) as *mut c_char) = '=' as c_char;
+ // *((name as usize + namelen as usize) as * mut c_char) = '=' as c_char;
+ namelen += 1;
+
+ if value != std::ptr::null_mut() && (*value) != 0 {
+ libc::strcpy(name.offset(namelen as isize), value);
+ } else {
+ *(name.offset(namelen as isize) as *mut c_char) =
+ '\0' as c_char;
+ }
+
+ offset = assignment(name, 0);
+ /* if offset was valid previously, but the substituting
+ of the nameref value results in an invalid assignment,
+ throw an invalid identifier error */
+ if offset == 0 {
+ libc::free(oldname as *mut c_void);
+ sh_invalidid(name);
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ *(name.offset(offset as isize)) = '\0' as c_char;
+
+ value = name.offset(namelen as isize);
+ }
+ libc::free(oldname as *mut c_void);
+
+ /* OK, let's turn off the nameref attribute.
+ Now everything else applies to VAR. */
+ if (flags_off & att_nameref!()) != 0 {
+ VUNSETATTR(refvar, att_nameref!());
+ }
+
+ //goto restart_new_var_name;
+ continue 'inner;
+ /* NOTREACHED */
+ }
+ }
+ if var == std::ptr::null_mut() {
+ var = r_declare_find_variable(name, mkglobal, chklocal);
+ }
+
+ var_exists = (var != std::ptr::null_mut()) as i32;
+ array_exists = (var != std::ptr::null_mut()
+ && (array_p(var) != 0 || assoc_p(var) != 0))
+ as i32;
+ creating_array = flags_on & (att_array!() | att_assoc!());
+
+ if var == std::ptr::null_mut() {
+ if (flags_on & att_assoc!()) != 0 {
+ var = make_new_assoc_variable(name);
+ if var != std::ptr::null_mut() && offset == 0 {
+ VSETATTR(var, att_invisible!());
+ }
+ } else if (flags_on & att_array!()) != 0 || making_array_special != 0 {
+ var = make_new_array_variable(name);
+ if var != std::ptr::null_mut() && offset == 0 {
+ VSETATTR(var, att_invisible!());
+ }
+ } else {
+ if mkglobal != 0 {
+ var =
+ bind_global_variable(name, std::ptr::null_mut(), ASS_FORCE!());
+ } else {
+ var = bind_variable(name, std::ptr::null_mut(), ASS_FORCE!());
+ }
+ if var != std::ptr::null_mut() && offset == 0 {
+ VSETATTR(var, att_invisible!());
+ }
+ }
+
+ if var == std::ptr::null_mut() {
+ /* Has to appear in brackets */
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ created_var = 1;
+ } else if (array_p(var) != 0 || assoc_p(var) != 0)
+ && (flags_on & att_nameref!()) != 0
+ {
+ /* Can't take an existing array variable and make it a nameref */
+ builtin_error(
+ CString::new("%s: reference variable cannot be an array")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ } else if nameref_p(var) != 0
+ && (flags_on & att_nameref!()) == 0
+ && (flags_off & att_nameref!()) == 0
+ && offset != 0
+ && valid_nameref_value(value, 1) == 0
+ {
+ builtin_error(
+ CString::new("`%s': invalid variable name for name reference")
+ .unwrap()
+ .as_ptr(),
+ value,
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ } else if (flags_on & att_nameref!()) != 0 {
+ /* Check of offset is to allow an assignment to a nameref var as
+ part of the declare word to override existing value */
+ if nameref_p(var) == 0
+ && var_isset(var)
+ && offset == 0
+ && valid_nameref_value(value_cell(var), 0) == 0
+ {
+ builtin_error(
+ CString::new("`%s': invalid variable name for name reference")
+ .unwrap()
+ .as_ptr(),
+ value_cell(var),
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if readonly_p(var) != 0 {
+ sh_readonly(name);
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ /* ksh93 compat: turning on nameref attribute turns off -ilu */
+ VUNSETATTR(
+ var,
+ att_integer!() | att_uppercase!() | att_lowercase!() | att_capcase!(),
+ );
+ }
+
+ /* Cannot use declare +r to turn off readonly attribute. */
+ if readonly_p(var) != 0 && (flags_off & att_readonly!()) != 0 {
+ sh_readonly((*var).name);
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ /* Cannot use declare to assign value to readonly or noassign
+ variable. */
+ if (readonly_p(var) != 0 || noassign_p(var) != 0) && offset != 0 {
+ if readonly_p(var) != 0 {
+ sh_readonly(name);
+ }
+ assign_error += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ /* make declare a[2]=foo as similar to a[2]=foo as possible if
+ a is already an array or assoc variable. */
+ if array_subscript_assignment && array_exists != 0 && creating_array == 0 {
+ simple_array_assign = 1;
+ } else if (making_array_special != 0
+ || creating_array != 0
+ || array_exists != 0)
+ && offset != 0
+ {
+ let vlen: i32;
+ vlen = libc::strlen(value) as i32;
+ /*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/
+ if shell_compatibility_level > 43
+ && (wflags & W_COMPASSIGN!()) == 0
+ && *value == '(' as c_char
+ && *(value.offset((vlen - 1) as isize) as *mut c_char) == ')' as c_char
+ {
+ /* The warning is only printed when using compound assignment
+ to an array variable that doesn't already exist. We use
+ creating_array to allow things like
+ declare -a foo$bar='(abc)' to work. */
+ if array_exists == 0 && creating_array == 0 {
+ internal_warning(
+ CString::new("%s: quoted compound array assignment deprecated")
+ .unwrap()
+ .as_ptr(),
+ (*(*list).word).word,
+ );
+ }
+ compound_array_assign =
+ (array_exists != 0 || creating_array != 0) as i32;
+ simple_array_assign = making_array_special;
+ } else if *value == '(' as c_char
+ && *(value.offset((vlen - 1) as isize) as *mut c_char) == ')' as c_char
+ && (shell_compatibility_level < 44 || (wflags & W_COMPASSIGN!()) != 0)
+ {
+ compound_array_assign = 1;
+ } else {
+ simple_array_assign = 1;
+ }
+ }
+
+ /* Cannot use declare +a name or declare +A name to remove an
+ array variable. */
+ if ((flags_off & att_array!()) != 0 && array_p(var) != 0)
+ || ((flags_off & att_assoc!()) != 0 && assoc_p(var) != 0)
+ {
+ builtin_error(
+ CString::new("%s: cannot destroy array variables in this way")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if (flags_on & att_array!()) != 0 && assoc_p(var) != 0 {
+ builtin_error(
+ CString::new("%s: cannot convert associative to indexed array")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ if (flags_on & att_assoc!()) != 0 && array_p(var) != 0 {
+ builtin_error(
+ CString::new("%s: cannot convert indexed to associative array")
+ .unwrap()
+ .as_ptr(),
+ name,
+ );
+ any_failed += 1;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+
+ /* declare -A name[[n]] makes name an associative array variable. */
+ if (flags_on & att_assoc!()) != 0 {
+ if assoc_p(var) == 0 {
+ var = convert_var_to_assoc(var);
+ }
+ } else if (making_array_special != 0 || (flags_on & att_array!()) != 0)
+ && array_p(var) == 0
+ && assoc_p(var) == 0
+ {
+ /* declare -a name[[n]] or declare name[n] makes name an indexed
+ array variable. */
+ var = convert_var_to_array(var);
+ }
+
+ /* XXX - we note that we are turning on nameref attribute and defer
+ setting it until the assignment has been made so we don't do an
+ inadvertent nameref lookup. Might have to do the same thing for
+ flags_off&att_nameref. */
+ /* XXX - ksh93 makes it an error to set a readonly nameref variable
+ using a single typeset command. */
+ onref = flags_on & att_nameref!();
+ flags_on &= !att_nameref!();
+
+ if array_p(var) != 0
+ || assoc_p(var) != 0
+ || (offset != 0 && compound_array_assign != 0)
+ || simple_array_assign != 0
+ {
+ onref = 0; /* array variables may not be namerefs */
+ }
+ /* ksh93 seems to do this */
+ offref = flags_off & att_nameref!();
+ flags_off &= !att_nameref!();
+
+ VSETATTR(var, flags_on);
+ VUNSETATTR(var, flags_off);
+
+ if offset != 0 && compound_array_assign != 0 {
+ assign_array_var_from_string(var, value, aflags | ASS_FORCE!());
+ } else if simple_array_assign != 0 && subscript_start != std::ptr::null_mut() {
+ let mut local_aflags: i32;
+ /* declare [-aA] name[N]=value */
+ *subscript_start = '[' as c_char; /* ] */
+ /* XXX - problem here with appending */
+ local_aflags = aflags & ASS_APPEND!();
+ if assoc_noexpand {
+ local_aflags |= ASS_NOEXPAND!();
+ } else {
+ local_aflags |= 0;
+ }
+
+ var = assign_array_element(name, value, local_aflags); /* XXX - not aflags */
+ *subscript_start = '\0' as c_char;
+ if var == std::ptr::null_mut() {
+ /* some kind of assignment error */
+ assign_error += 1;
+ flags_on |= onref;
+ flags_off |= offref;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ } else if simple_array_assign != 0 {
+ /* let bind_{array,assoc}_variable take care of this. */
+ if assoc_p(var) != 0 {
+ bind_assoc_variable(
+ var,
+ name,
+ r_savestring(CString::new("0").unwrap().as_ptr()),
+ value,
+ aflags | ASS_FORCE!(),
+ );
+ } else {
+ bind_array_variable(name, 0, value, aflags | ASS_FORCE!());
+ }
+ } else if offset != 0 {
+ /* XXX - no ASS_FORCE here */
+ /* bind_variable_value duplicates the essential internals of bind_variable() */
+ if onref != 0 || nameref_p(var) != 0 {
+ aflags |= ASS_NAMEREF!();
+ }
+
+ v = bind_variable_value(var, value, aflags);
+ if v == std::ptr::null_mut() && (onref != 0 || nameref_p(var) != 0) {
+ if valid_nameref_value(value, 1) == 0 {
+ sh_invalidid(value);
+ }
+
+ assign_error += 1;
+ /* XXX - unset this variable? or leave it as normal var? */
+ if created_var != 0 {
+ if mkglobal != 0 {
+ delete_var((*var).name, global_variables);
+ } else {
+ delete_var((*var).name, shell_variables);
+ }
+ }
+
+ flags_on |= onref; /* undo change from above */
+ flags_off |= offref;
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
+ }
+
+ /* If we found this variable in the temporary environment, as with
+ `var=value declare -x var', make sure it is treated identically
+ to `var=value export var'. Do the same for `declare -r' and
+ `readonly'. Preserve the attributes, except for att_tempvar. */
+ /* XXX -- should this create a variable in the global scope, or
+ modify the local variable flags? ksh93 has it modify the
+ global scope.
+ Need to handle case like in set_var_attribute where a temporary
+ variable is in the same table as the function local vars. */
+ if (flags_on & (att_exported!() | att_readonly!()) != 0) && tempvar_p(var) != 0
+ {
+ let mut tv: *mut SHELL_VAR;
+ let mut tvalue: *mut c_char = std::ptr::null_mut();
+
+ tv = find_tempenv_variable((*var).name);
+ if tv != std::ptr::null_mut() {
+ if var_isset(var) {
+ tvalue = r_savestring(value_cell(var));
+ } else {
+ tvalue = r_savestring(CString::new("").unwrap().as_ptr());
+ }
+ tv = bind_variable((*var).name, tvalue, 0);
+
+ if tv != std::ptr::null_mut() {
+ (*tv).attributes |= (*var).attributes & !att_tempvar!();
+ if (*tv).context > 0 {
+ VSETATTR(tv, att_propagate!());
+ }
+ }
+ libc::free(tvalue as *mut c_void);
+ }
+ VSETATTR(var, att_propagate!());
+ }
+ }
+
+ /* Turn on nameref attribute we deferred above. */
+ /* XXX - should we turn on the noassign attribute for consistency with
+ ksh93 when we turn on the nameref attribute? */
+ VSETATTR(var, onref);
+ flags_on |= onref;
+ VUNSETATTR(var, offref);
+ flags_off |= offref;
+ /* Yuck. ksh93 compatibility. XXX - need to investigate more but
+ definitely happens when turning off nameref attribute on nameref
+ (see comments above). Under no circumstances allow this to turn
+ off readonly attribute on readonly nameref variable. */
+ if refvar != std::ptr::null_mut() {
+ if (flags_off & att_readonly!()) != 0 {
+ flags_off &= !att_readonly!();
+ }
+ VUNSETATTR(refvar, flags_off);
+ }
+ stupidly_hack_special_variables(name);
+ libc::free(name as *mut c_void);
+ list = (*list).next;
+ continue 'outter;
+ }
}
- list = (*list).next;
- }
-
- if any_failed !=0 {
- return EXECUTION_FAILURE!();
- } else {
- return EXECUTION_SUCCESS!();
- }
- }
- let tmpValue = CString::new("").unwrap();
-
- /* There are arguments left, so we are making variables. */
- 'outter: while list !=std::ptr::null_mut() { /* declare [-aAfFirx] name [name ...] */
- let mut value:* mut c_char;
- let mut name:* mut c_char;
- let mut oldname:* mut c_char;
- let mut offset:i32;
- let mut aflags:i32;
- let wflags:i32;
- let mut created_var:i32;
- let mut namelen:i32;
- let assoc_noexpand:bool;
-
- let mut making_array_special:i32;
- let mut compound_array_assign:i32;
- let mut simple_array_assign:i32;
- let mut var_exists:i32;
- let mut array_exists:i32;
- let mut creating_array:i32;
- let mut array_subscript_assignment:bool;
-
- name = r_savestring ((*(*list).word).word);
- wflags = (*(*list).word).flags;
-
- assoc_noexpand = (assoc_expand_once !=0 && (wflags & (1 << 2)) !=0);
- // 分出=
- if assoc_noexpand {
- offset = assignment (name, 2);
- } else {
- offset = assignment (name, 0);
- }
-
- aflags = 0;
- created_var = 0;
-
- if local_var !=0 && variable_context !=0 && STREQ (name, CString::new("-").unwrap().as_ptr()) {
- var = make_local_variable (CString::new("-").unwrap().as_ptr(), 0);
- if value_cell(var) != std::ptr::null_mut() {
- libc::free (value_cell (var) as * mut c_void); /* just in case */
+ if assign_error != 0 {
+ return EX_BADASSIGN!();
+ } else {
+ if any_failed == 0 {
+ return EXECUTION_SUCCESS!();
+ } else {
+ return EXECUTION_FAILURE!();
+ }
}
- value = get_current_options ();
- var_setvalue (var, value);
- VSETATTR (var, att_invisible!());
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if offset !=0 { /* declare [-aAfFirx] name=value */
- *name.offset(offset as isize) = '\0' as c_char;
- value = name.offset((offset + 1) as isize) ;
- if *(name.offset((offset - 1) as isize)) == '+' as c_char {
- aflags |= ASS_APPEND!();
- *(name.offset((offset - 1) as isize))= '\0' as c_char;
- }
- } else {
- value = tmpValue.as_ptr() as * mut c_char;
- }
- /* Do some lexical error checking on the LHS and RHS of the assignment
- that is specific to nameref variables. */
- if (flags_on & att_nameref!()) !=0 {
- if valid_array_reference (name, 0) !=0 {
- builtin_error (CString::new("%s: reference variable cannot be an array").unwrap().as_ptr(), name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- } else if check_selfref (name, value, 0) !=0 {/* disallow self references at global scope, warn at function scope */
- if variable_context == 0 {
- builtin_error (CString::new("%s: nameref variable self references not allowed").unwrap().as_ptr(), name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- } else {
- builtin_warning (CString::new("%s: circular name reference").unwrap().as_ptr(), name);
- }
- }
-
- if value != std::ptr::null_mut() && (*value) !=0 && (aflags & ASS_APPEND!()) == 0 && valid_nameref_value (value, 1) == 0 {
- builtin_error (CString::new("`nvalid %s': ivariable name for name reference").unwrap().as_ptr(), value);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- }
-//restart_new_var_name:
- 'inner: loop {
- var_exists = 0;
- array_exists = 0;
- creating_array = 0;
- compound_array_assign = 0;
- simple_array_assign = 0;
- array_subscript_assignment = false;
- subscript_start = std::ptr::null_mut();
- t = libc::strchr (name, '[' as libc::c_int);
- if t !=std::ptr::null_mut() && (flags_on & att_function!()) == 0 {/* ] */
- /* If offset != 0 we have already validated any array reference
- because assignment() calls skipsubscript() */
- if offset == 0 && valid_array_reference (name, 0) == 0 {
- sh_invalidid (name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- subscript_start = t;
- *t = '\0' as c_char;
- making_array_special = 1; /* XXX - should this check offset? */
- array_subscript_assignment = offset != 0;
- } else {
- making_array_special = 0;
- }
- /* If we're in posix mode or not looking for a shell function (since
- shell function names don't have to be valid identifiers when the
- shell's not in posix mode), check whether or not the argument is a
- valid, well-formed shell identifier. */
- if (posixly_correct !=0 || (flags_on & att_function!()) == 0) && legal_identifier(name) == 0 {
- sh_invalidid (name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- /* If VARIABLE_CONTEXT has a non-zero value, then we are executing
- inside of a function. This means we should make local variables,
- not global ones. */
-
- /* XXX - this has consequences when we're making a local copy of a
- variable that was in the temporary environment. Watch out
- for this. */
- refvar = std::ptr::null_mut();
- if variable_context !=0 && mkglobal == 0 && ((flags_on & att_function!()) == 0) {
- let newname: * mut c_char;
-
- /* check name for validity here? */
- var = find_variable (name);
- if var == std::ptr::null_mut() {
- newname = nameref_transform_name (name, ASS_MKLOCAL!());
- }
- else if (flags_on & att_nameref!()) == 0 && (flags_off & att_nameref!()) == 0 {
- /* Ok, we're following namerefs here, so let's make sure that if
- we followed one, it was at the same context (see below for
- more details). */
- refvar = find_variable_last_nameref (name, 1);
- if refvar != std::ptr::null_mut() && (*refvar).context != variable_context {
- newname = name ;
- }
- else {
- newname = (*var).name;
- }
- refvar = std::ptr::null_mut();
- } else {
- newname = name; /* dealing with nameref attribute */
- }
-// 至此,find_variable 返回var 没有被更新
- /* Pass 1 as second argument to make_local_{assoc,array}_variable
- return an existing {array,assoc} variable to be flagged as an
- error below. */
- if (flags_on & att_assoc!()) !=0 {
- var = make_local_assoc_variable (newname, MKLOC_ARRAYOK!()|inherit_flag);
- } else if (flags_on & att_array!()) !=0 || making_array_special !=0 {
- var = make_local_array_variable (newname, MKLOC_ASSOCOK!()|inherit_flag);
- } else if offset == 0 && (flags_on & att_nameref!()) !=0 {
- /* First look for refvar at current scope */
- refvar = find_variable_last_nameref (name, 1);
- /* VARIABLE_CONTEXT != 0, so we are attempting to create or modify
- the attributes for a local variable at the same scope. If we've
- used a reference from a previous context to resolve VAR, we
- want to throw REFVAR and VAR away and create a new local var. */
- if refvar != std::ptr::null_mut() && (*refvar).context != variable_context {
- refvar = std::ptr::null_mut();
- var = make_local_variable (name, inherit_flag);
- } else if refvar != std::ptr::null_mut() && (*refvar).context == variable_context {
- var = refvar;
- } else if var == std::ptr::null_mut() || (*refvar).context != variable_context {/* Maybe we just want to create a new local variable */
- var = make_local_variable (name, inherit_flag);
- }
- /* otherwise we have a var at the right context */
- } else {
- /* XXX - check name for validity here with valid_nameref_value */
- if flags_on & att_nameref!() !=0 {
- var = make_local_variable ( name , inherit_flag);
- } else {
- var = make_local_variable ( newname, inherit_flag); /* sets att_invisible for new vars */
- }
- }
-
- if var == std::ptr::null_mut() {
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if var != std::ptr::null_mut() && nameref_p (var) !=0 && readonly_p (var) != 0 && nameref_cell (var) != std::ptr::null_mut() && (flags_off & att_nameref!()) !=0 {
- sh_readonly (name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- } else {
- var = std::ptr::null_mut();
- }
- /* If we are declaring a function, then complain about it in some way.
- We don't let people make functions by saying `typeset -f foo=bar'. */
-
- /* There should be a way, however, to let people look at a particular
- function definition by saying `typeset -f foo'. */
-
- if (flags_on & att_function!()) !=0 {
- if offset !=0 { /* declare -f [-rix] foo=bar */
- builtin_error (CString::new("cannot use `-f' to make functions").unwrap().as_ptr());
- libc::free (name as * mut c_void);
- return EXECUTION_FAILURE!();
- } else {/* declare -f [-rx] name [name...] */
- var = find_function (name);
- if var != std::ptr::null_mut() {
- if readonly_p (var) !=0 && (flags_off & att_readonly!()) !=0 {
- builtin_error (CString::new("%s: readonly function").unwrap().as_ptr(), name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- } else if (flags_on & (att_array!()|att_assoc!())) !=0 {
- if (flags_on & att_array!()) !=0 {
- sh_invalidopt (CString::new("-a").unwrap().as_ptr() as * mut c_char);
- } else {
- sh_invalidopt (CString::new("-A").unwrap().as_ptr() as * mut c_char);
- }
-
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- /* declare -[Ff] name [name...] */
- if flags_on == att_function!() && flags_off == 0 {
- if nodefs !=0 && debugging_mode !=0 {
- shell_fn = find_function_def ((*var).name);
- if shell_fn !=std::ptr::null_mut() {
- println!("{} {} {}",CStr::from_ptr((*var).name).to_str().unwrap(),(*shell_fn).line,CStr::from_ptr((*shell_fn).source_file).to_str().unwrap());
- } else {
- println!("{}",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- } else {
- if nodefs !=0 {
- t=(*var).name;
- } else {
- t = named_function_string (name, function_cell (var), FUNC_MULTILINE!()|FUNC_EXTERNAL!());
- }
- println!("{}",CStr::from_ptr(t).to_str().unwrap());
- any_failed = sh_chkwrite (any_failed);
- }
- } else { /* declare -[fF] -[rx] name [name...] */
- VSETATTR (var, flags_on);
- flags_off &= ! att_function!(); /* makes no sense */
- VUNSETATTR (var, flags_off);
- }
- } else {
- any_failed+=1;
- }
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- } else {
- /* declare -[aAinrx] name [name...] */
- /* Non-null if we just created or fetched a local variable. */
-
- /* Here's what ksh93 seems to do as of the 2012 version: if we are
- using declare -n to modify the value of an existing nameref
- variable, don't follow the nameref chain at all and just search
- for a nameref at the current context. If we have a nameref,
- modify its value (changing which variable #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */it references). */
- if var == std::ptr::null_mut() && (flags_on & att_nameref!()) !=0 {
- /* See if we are trying to modify an existing nameref variable,
- but don't follow the nameref chain. */
- if mkglobal !=0 {
- var = find_global_variable_noref (name);
- } else {
- var = find_variable_noref (name);
- }
-
- if var != std::ptr::null_mut() && nameref_p (var) == 0 {
- var = std::ptr::null_mut();
- }
- } else if var == std::ptr::null_mut() && (flags_off & att_nameref!()) !=0 {
- /* However, if we're turning off the nameref attribute on an existing
- nameref variable, we first follow the nameref chain to the end,
- modify the value of the variable this nameref variable references
- if there is an assignment statement argument,
- *CHANGING ITS VALUE AS A SIDE EFFECT*, then turn off the nameref
- flag *LEAVING THE NAMEREF VARIABLE'S VALUE UNCHANGED* */
- /* See if we are trying to modify an existing nameref variable */
- if mkglobal !=0 {
- refvar=find_global_variable_last_nameref (name, 0);
- } else {
- refvar=find_variable_last_nameref (name, 0);
- }
-
- if refvar != std::ptr::null_mut() && nameref_p (refvar) == 0 {
- refvar = std::ptr::null_mut();
- }
- /* If the nameref is readonly but doesn't have a value, ksh93
- allows the nameref attribute to be removed. If it's readonly
- and has a value, even if the value doesn't reference an
- existing variable, we disallow the modification */
- if refvar != std::ptr::null_mut() && nameref_cell (refvar) != std::ptr::null_mut() && readonly_p (refvar) != 0 {
- sh_readonly (name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- /* If all we're doing is turning off the nameref attribute, don't
- bother with VAR at all, whether it exists or not. Just turn it
- off and go on. */
- if refvar != std::ptr::null_mut() && flags_on == 0 && offset == 0 && (flags_off & !att_nameref!()) == 0 {
- VUNSETATTR (refvar, att_nameref!());
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if refvar !=std::ptr::null_mut() {
- /* XXX - use declare_find_variable here? */
- if mkglobal !=0 {
- var = find_global_variable (nameref_cell (refvar));
- } else {
- var =find_variable (nameref_cell (refvar));
- }
- }
- } else if var == std::ptr::null_mut() && offset !=0 && array_subscript_assignment {
- /* If we have an array assignment to a nameref, remove the nameref
- attribute and go on. */
- if mkglobal !=0 {
- var = find_global_variable_noref (name);
- } else {
- var = find_variable_noref (name);
- }
-
- if var !=std::ptr::null_mut() && nameref_p (var) !=0 {
- internal_warning (CString::new("%s: removing nameref attribute").unwrap().as_ptr(), name);
- libc::free (value_cell (var) as * mut c_void); /* XXX - bash-4.3 compat */
- var_setvalue (var, std::ptr::null_mut());
- VUNSETATTR (var, att_nameref!());
- }
- }
-
- /* See if we are trying to set flags or value (or create) for an
- existing nameref that points to a non-existent variable: e.g.,
- declare -n foo=bar
- unset foo # unsets bar
- declare -i foo
- foo=4+4
- declare -p foo */
- if var == std::ptr::null_mut() && (mkglobal !=0 || flags_on !=0 || flags_off !=0 || offset !=0) {
- if mkglobal !=0 {
- refvar = find_global_variable_last_nameref (name, 0);
- } else {
- refvar = find_variable_last_nameref (name, 0);
- }
-
- if refvar != std::ptr::null_mut() && nameref_p (refvar) == 0 {
- refvar = std::ptr::null_mut();
- }
-
- if refvar !=std::ptr::null_mut() {
- /* XXX - use declare_find_variable here? */
- if mkglobal !=0 {
- var = find_global_variable (nameref_cell (refvar)) ;
- } else {
- var = find_variable (nameref_cell (refvar));
- }
- }
-
- if refvar !=std::ptr::null_mut() && var == std::ptr::null_mut() {
- oldname = name; /* need to free this */
- namelen = libc::strlen (nameref_cell (refvar)) as i32;
-
- if subscript_start != std::ptr::null_mut() {
- *subscript_start = '[' as c_char; /*]*/
- namelen += libc::strlen (subscript_start) as i32;
- }
-
- name = libc::malloc (namelen as libc::size_t + 2 + libc::strlen (value) + 1 ) as * mut c_char ;
- libc::strcpy (name, nameref_cell (refvar));
-
- if subscript_start != std::ptr::null_mut() {
- libc::strcpy (name.offset(libc::strlen (nameref_cell (refvar)) as isize), subscript_start);
- }
-
- /* We are committed to using the new name, so reset */
- if offset !=0 {
- /* Rebuild assignment and restore offset and value */
- if (aflags & ASS_APPEND!()) !=0 {
- *(name.offset( namelen as isize) as * mut c_char) = '+' as c_char;
-
- namelen+=1;
- }
- *(name.offset( namelen as isize) as * mut c_char) = '=' as c_char;
- // *((name as usize + namelen as usize) as * mut c_char) = '=' as c_char;
- namelen+=1;
-
- if value != std::ptr::null_mut() && (*value) !=0 {
- libc::strcpy (name.offset(namelen as isize), value);
- } else {
- *(name.offset( namelen as isize) as * mut c_char) = '\0' as c_char;
- }
-
- offset = assignment (name, 0);
- /* if offset was valid previously, but the substituting
- of the nameref value results in an invalid assignment,
- throw an invalid identifier error */
- if offset == 0 {
- libc::free (oldname as * mut c_void);
- sh_invalidid (name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- *(name.offset(offset as isize)) = '\0' as c_char;
-
- value = name.offset(namelen as isize) ;
- }
- libc::free (oldname as * mut c_void);
-
- /* OK, let's turn off the nameref attribute.
- Now everything else applies to VAR. */
- if (flags_off & att_nameref!()) !=0 {
- VUNSETATTR (refvar, att_nameref!());
- }
-
- //goto restart_new_var_name;
- continue 'inner;
- /* NOTREACHED */
- }
- }
- if var == std::ptr::null_mut() {
- var = r_declare_find_variable (name, mkglobal, chklocal);
- }
-
- var_exists = (var != std::ptr::null_mut()) as i32;
- array_exists = (var != std::ptr::null_mut() && (array_p (var) !=0 || assoc_p (var) !=0 )) as i32;
- creating_array = flags_on & (att_array!()|att_assoc!());
-
- if var == std::ptr::null_mut() {
- if (flags_on & att_assoc!()) !=0 {
- var = make_new_assoc_variable (name);
- if var != std::ptr::null_mut() && offset == 0 {
- VSETATTR (var, att_invisible!());
- }
- } else if (flags_on & att_array!()) !=0 || making_array_special !=0 {
- var = make_new_array_variable (name);
- if var != std::ptr::null_mut() && offset == 0 {
- VSETATTR (var, att_invisible!());
- }
- } else {
- if mkglobal !=0 {
- var=bind_global_variable (name, std::ptr::null_mut(), ASS_FORCE!());
- } else {
- var= bind_variable (name, std::ptr::null_mut(), ASS_FORCE!());
- }
- if var != std::ptr::null_mut() && offset == 0 {
- VSETATTR (var, att_invisible!());
- }
- }
-
- if var == std::ptr::null_mut() {
- /* Has to appear in brackets */
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- created_var = 1;
- } else if (array_p (var) !=0 || assoc_p (var) !=0 ) && (flags_on & att_nameref!()) !=0 {
- /* Can't take an existing array variable and make it a nameref */
- builtin_error (CString::new("%s: reference variable cannot be an array").unwrap().as_ptr(), name);
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- } else if nameref_p (var) !=0 && (flags_on & att_nameref!()) == 0 && (flags_off & att_nameref!()) == 0 && offset !=0 && valid_nameref_value (value, 1) == 0 {
- builtin_error (CString::new("`%s': invalid variable name for name reference").unwrap().as_ptr(), value);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- } else if (flags_on & att_nameref!()) !=0 {
- /* Check of offset is to allow an assignment to a nameref var as
- part of the declare word to override existing value */
- if nameref_p (var) == 0 && var_isset (var) && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0 {
- builtin_error (CString::new("`%s': invalid variable name for name reference").unwrap().as_ptr(), value_cell (var));
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if readonly_p (var) !=0 {
- sh_readonly (name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- /* ksh93 compat: turning on nameref attribute turns off -ilu */
- VUNSETATTR (var, att_integer!()|att_uppercase!()|att_lowercase!()|att_capcase!());
- }
-
- /* Cannot use declare +r to turn off readonly attribute. */
- if readonly_p (var) !=0 && (flags_off & att_readonly!()) !=0 {
- sh_readonly ((*var).name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- /* Cannot use declare to assign value to readonly or noassign
- variable. */
- if (readonly_p (var) !=0 || noassign_p (var)!=0 ) && offset !=0 {
- if readonly_p (var) !=0 {
- sh_readonly (name);
- }
- assign_error+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- /* make declare a[2]=foo as similar to a[2]=foo as possible if
- a is already an array or assoc variable. */
- if array_subscript_assignment && array_exists !=0 && creating_array == 0 {
- simple_array_assign = 1;
- } else if (making_array_special !=0 || creating_array !=0 || array_exists !=0) && offset!=0 {
- let mut vlen:i32;
- vlen = libc::strlen (value) as i32;
- /*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/
- if shell_compatibility_level > 43 && (wflags & W_COMPASSIGN!()) == 0 && *value == '(' as c_char && *(value.offset((vlen-1) as isize) as * mut c_char) == ')' as c_char {
- /* The warning is only printed when using compound assignment
- to an array variable that doesn't already exist. We use
- creating_array to allow things like
- declare -a foo$bar='(abc)' to work. */
- if array_exists == 0 && creating_array == 0 {
- internal_warning (CString::new("%s: quoted compound array assignment deprecated").unwrap().as_ptr(), (*(*list).word).word);
- }
- compound_array_assign = (array_exists !=0 || creating_array !=0) as i32;
- simple_array_assign = making_array_special;
- } else if *value == '(' as c_char && *(value.offset((vlen-1) as isize) as * mut c_char) == ')' as c_char && (shell_compatibility_level < 44 || (wflags & W_COMPASSIGN!()) !=0 ) {
- compound_array_assign = 1;
- } else {
- simple_array_assign = 1;
- }
- }
-
- /* Cannot use declare +a name or declare +A name to remove an
- array variable. */
- if ((flags_off & att_array!()) !=0 && array_p (var) !=0) || ((flags_off & att_assoc!()) !=0 && assoc_p (var) !=0) {
- builtin_error (CString::new("%s: cannot destroy array variables in this way").unwrap().as_ptr(), name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if (flags_on & att_array!()) !=0 && assoc_p (var) !=0 {
- builtin_error (CString::new("%s: cannot convert associative to indexed array").unwrap().as_ptr(), name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- if (flags_on & att_assoc!()) !=0 && array_p (var) !=0 {
- builtin_error (CString::new("%s: cannot convert indexed to associative array").unwrap().as_ptr(), name);
- any_failed+=1;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
-
- /* declare -A name[[n]] makes name an associative array variable. */
- if (flags_on & att_assoc!()) !=0 {
- if assoc_p (var) == 0 {
- var = convert_var_to_assoc (var);
- }
- } else if (making_array_special !=0 || (flags_on & att_array!()) !=0 ) && array_p (var) == 0 && assoc_p (var) == 0 {
- /* declare -a name[[n]] or declare name[n] makes name an indexed
- array variable. */
- var = convert_var_to_array (var);
- }
-
- /* XXX - we note that we are turning on nameref attribute and defer
- setting it until the assignment has been made so we don't do an
- inadvertent nameref lookup. Might have to do the same thing for
- flags_off&att_nameref. */
- /* XXX - ksh93 makes it an error to set a readonly nameref variable
- using a single typeset command. */
- onref = flags_on & att_nameref!();
- flags_on &= !att_nameref!();
-
- if array_p (var) !=0 || assoc_p (var) !=0 || (offset !=0 && compound_array_assign !=0) || simple_array_assign !=0 {
- onref = 0; /* array variables may not be namerefs */
- }
- /* ksh93 seems to do this */
- offref = flags_off & att_nameref!();
- flags_off &= !att_nameref!();
-
- VSETATTR (var, flags_on);
- VUNSETATTR (var, flags_off);
-
- if offset !=0 && compound_array_assign !=0 {
- assign_array_var_from_string (var, value, aflags|ASS_FORCE!());
- } else if simple_array_assign !=0 && subscript_start !=std::ptr::null_mut() {
- let mut local_aflags:i32;
- /* declare [-aA] name[N]=value */
- *subscript_start = '[' as c_char; /* ] */
- /* XXX - problem here with appending */
- local_aflags = aflags&ASS_APPEND!();
- if assoc_noexpand {
- local_aflags |= ASS_NOEXPAND!();
- } else {
- local_aflags |= 0;
- }
-
- var = assign_array_element (name, value, local_aflags); /* XXX - not aflags */
- *subscript_start = '\0' as c_char;
- if var == std::ptr::null_mut() {/* some kind of assignment error */
- assign_error+=1;
- flags_on |= onref;
- flags_off |= offref;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- } else if simple_array_assign !=0 {
- /* let bind_{array,assoc}_variable take care of this. */
- if assoc_p (var) !=0 {
- bind_assoc_variable (var, name, r_savestring (CString::new("0").unwrap().as_ptr()), value, aflags|ASS_FORCE!());
- } else {
- bind_array_variable (name, 0, value, aflags|ASS_FORCE!());
- }
- } else if offset !=0 {
- /* XXX - no ASS_FORCE here */
- /* bind_variable_value duplicates the essential internals of bind_variable() */
- if onref !=0 || nameref_p (var) !=0 {
- aflags |= ASS_NAMEREF!();
- }
-
- v = bind_variable_value (var, value, aflags);
- if v == std::ptr::null_mut() && (onref !=0 || nameref_p (var) !=0) {
- if valid_nameref_value (value, 1) == 0 {
- sh_invalidid (value);
- }
-
- assign_error+=1;
- /* XXX - unset this variable? or leave it as normal var? */
- if created_var !=0 {
- if mkglobal !=0 {
- delete_var ( (*var).name, global_variables);
- } else {
- delete_var ( (*var).name, shell_variables);
- }
- }
-
- flags_on |= onref;/* undo change from above */
- flags_off |= offref;
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- }
-
- /* If we found this variable in the temporary environment, as with
- `var=value declare -x var', make sure it is treated identically
- to `var=value export var'. Do the same for `declare -r' and
- `readonly'. Preserve the attributes, except for att_tempvar. */
- /* XXX -- should this create a variable in the global scope, or
- modify the local variable flags? ksh93 has it modify the
- global scope.
- Need to handle case like in set_var_attribute where a temporary
- variable is in the same table as the function local vars. */
- if (flags_on & (att_exported!()|att_readonly!()) !=0 ) && tempvar_p (var) !=0 {
- let mut tv:* mut SHELL_VAR;
- let mut tvalue:* mut c_char=std::ptr::null_mut();
-
- tv = find_tempenv_variable ((*var).name);
- if tv != std::ptr::null_mut() {
- if var_isset(var) {
- tvalue = r_savestring (value_cell (var));
- } else {
- tvalue = r_savestring (CString::new("").unwrap().as_ptr());
- }
- tv = bind_variable ((*var).name, tvalue, 0);
-
- if tv != std::ptr::null_mut() {
- (*tv).attributes |= (*var).attributes & !att_tempvar!();
- if (*tv).context > 0 {
- VSETATTR (tv, att_propagate!());
- }
- }
- libc::free (tvalue as * mut c_void);
- }
- VSETATTR (var, att_propagate!());
- }
- }
-
- /* Turn on nameref attribute we deferred above. */
- /* XXX - should we turn on the noassign attribute for consistency with
- ksh93 when we turn on the nameref attribute? */
- VSETATTR (var, onref);
- flags_on |= onref;
- VUNSETATTR (var, offref);
- flags_off |= offref;
- /* Yuck. ksh93 compatibility. XXX - need to investigate more but
- definitely happens when turning off nameref attribute on nameref
- (see comments above). Under no circumstances allow this to turn
- off readonly attribute on readonly nameref variable. */
- if refvar !=std::ptr::null_mut() {
- if (flags_off & att_readonly!()) !=0 {
- flags_off &= !att_readonly!();
- }
- VUNSETATTR (refvar, flags_off);
- }
- stupidly_hack_special_variables (name);
- libc::free (name as * mut c_void);
- list = (*list).next;
- continue 'outter;
- }
- }
- if assign_error !=0 {
- return EX_BADASSIGN!();
- } else {
- if any_failed == 0 {
- return EXECUTION_SUCCESS!();
- } else {
- return EXECUTION_FAILURE!();
- }
- }
-}
+ }
}
diff --git a/bash-5.1/builtins_rust/echo/src/lib.rs b/bash-5.1/builtins_rust/echo/src/lib.rs
index fc9b8bcc5c3882caffeccc5d64814eaed50d7969..62fb8bf458f1168ae941e5b03f2b79713422f7f8 100644
--- a/bash-5.1/builtins_rust/echo/src/lib.rs
+++ b/bash-5.1/builtins_rust/echo/src/lib.rs
@@ -5,10 +5,10 @@ extern crate libc;
use libc::{c_char,c_int, strchr, putchar,clearerr,free,FILE, fprintf, c_void};
use std::ffi::{CString,CStr,};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordList, EXECUTION_SUCCESS};
// use std::io::{stdout, Write};
use std::ptr::read_volatile;
-use rhelp::r_builtin_help;
+
//结构体
//枚举
diff --git a/bash-5.1/builtins_rust/enable/src/lib.rs b/bash-5.1/builtins_rust/enable/src/lib.rs
index be00f19fb6035208d7dd7f1febf1232919bc1781..5fc3d824bba624c9a82101a54f16c039fcffff46 100644
--- a/bash-5.1/builtins_rust/enable/src/lib.rs
+++ b/bash-5.1/builtins_rust/enable/src/lib.rs
@@ -1,14 +1,14 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use std::ffi::{CString,CStr};
+use std::ffi::{CStr, CString};
extern crate rcmd;
use libc::c_char;
-use std::path::Path;
use libloading::Library;
use rcmd::*;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
+use std::path::Path;
/*
#define ENABLED 1
#define DISABLED 2
@@ -32,8 +32,7 @@ pub const NFLAG: i32 = 0x08;
pub const PFLAG: i32 = 0x10;
pub const SFLAG: i32 = 0x20;
-
-// Flags describing various things about a builtin.
+// Flags describing various things about a builtin.
//#define BUILTIN_ENABLED 0x01 /* This builtin is enabled. */
//#define BUILTIN_DELETED 0x02 /* This has been deleted with enable -d. */
//#define STATIC_BUILTIN 0x04 /* This builtin is not dynamically loaded. */
@@ -44,15 +43,14 @@ pub const SFLAG: i32 = 0x20;
//#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */
//#define BASE_INDENT 4
-pub const BUILTIN_ENABLED :i32 = 0x01;
-pub const BUILTIN_DELETED :i32 = 0x02;
-pub const STATIC_BUILTIN :i32 = 0x04;
-pub const SPECIAL_BUILTIN :i32 = 0x08;
-pub const ASSIGNMENT_BUILTIN :i32 = 0x10;
-pub const POSIX_BUILTIN :i32 = 0x20;
-pub const LOCALVAR_BUILTIN :i32 = 0x40;
-pub const REQUIRES_BUILTIN :i32 = 0x80;
-
+pub const BUILTIN_ENABLED: i32 = 0x01;
+pub const BUILTIN_DELETED: i32 = 0x02;
+pub const STATIC_BUILTIN: i32 = 0x04;
+pub const SPECIAL_BUILTIN: i32 = 0x08;
+pub const ASSIGNMENT_BUILTIN: i32 = 0x10;
+pub const POSIX_BUILTIN: i32 = 0x20;
+pub const LOCALVAR_BUILTIN: i32 = 0x40;
+pub const REQUIRES_BUILTIN: i32 = 0x80;
/* The MODE argument to `dlopen' contains one of the following: */
// #define RTLD_LAZY 0x00001 /* Lazy function call binding. */
@@ -60,21 +58,20 @@ pub const REQUIRES_BUILTIN :i32 = 0x80;
// #define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
// #define RTLD_NOLOAD 0x00004 /* Do not load the object. */
// #define RTLD_DEEPBIND 0x00008 /* Use deep binding. */
-
/* If the following bit is set in the MODE argument to `dlopen',
- the symbols of the loaded object and its dependencies are made
- visible as if the object were linked directly into the program. */
+the symbols of the loaded object and its dependencies are made
+visible as if the object were linked directly into the program. */
// #define RTLD_GLOBAL 0x00100
-pub const RTLD_LAZY :i32 = 0x00001;
-pub const RTLD_NOW :i32 = 0x00002;
-pub const RTLD_BINDING_MASK :i32 = 0x3;
-pub const RTLD_NOLOAD :i32 = 0x00004;
-pub const RTLD_DEEPBIND :i32 = 0x00008;
-pub const RTLD_GLOBAL :i32 = 0x00100;
+pub const RTLD_LAZY: i32 = 0x00001;
+pub const RTLD_NOW: i32 = 0x00002;
+pub const RTLD_BINDING_MASK: i32 = 0x3;
+pub const RTLD_NOLOAD: i32 = 0x00004;
+pub const RTLD_DEEPBIND: i32 = 0x00008;
+pub const RTLD_GLOBAL: i32 = 0x00100;
-pub const FS_NODIRS :i32 = 0x20;
-pub const FS_EXEC_PREFERRED :i32 = 0x4;
+pub const FS_NODIRS: i32 = 0x20;
+pub const FS_EXEC_PREFERRED: i32 = 0x4;
extern "C" {
fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
@@ -117,10 +114,7 @@ extern "C" {
fn set_itemlist_dirty(_: *mut ITEMLIST);
fn dlopen(__file: *const libc::c_char, __mode: libc::c_int) -> *mut libc::c_void;
fn dlclose(__handle: *mut libc::c_void) -> libc::c_int;
- fn dlsym(
- __handle: *mut libc::c_void,
- __name: *const libc::c_char,
- ) -> *mut libc::c_void;
+ fn dlsym(__handle: *mut libc::c_void, __name: *const libc::c_char) -> *mut libc::c_void;
fn dlerror() -> *mut libc::c_char;
}
pub type size_t = libc::c_ulong;
@@ -139,7 +133,7 @@ pub type STRINGLIST = _list_of_strings;
#[repr(C)]
pub struct builtin {
pub name: *mut libc::c_char,
- pub function: Option::,
+ pub function: Option,
pub flags: libc::c_int,
pub long_doc: *const *mut libc::c_char,
pub short_doc: *const libc::c_char,
@@ -149,7 +143,7 @@ pub struct builtin {
#[repr(C)]
pub struct _list_of_items {
pub flags: libc::c_int,
- pub list_getter: Option:: libc::c_int>,
+ pub list_getter: Option libc::c_int>,
pub slist: *mut STRINGLIST,
pub genlist: *mut STRINGLIST,
pub genindex: libc::c_int,
@@ -163,9 +157,9 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
let mut filter: i32 = 0;
let mut filename: *mut libc::c_char = 0 as *mut libc::c_char;
reset_internal_getopt();
- let adnpsf = CString::new("adnpsf").expect("CString::new failed");;
+ let adnpsf = CString::new("adnpsf").expect("CString::new failed");
loop {
- opt = internal_getopt(list, adnpsf.as_ptr() );
+ opt = internal_getopt(list, adnpsf.as_ptr());
if !(opt != -1) {
break;
}
@@ -191,7 +185,7 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
flags |= DFLAG;
}
_ => {
- if opt ==-99 {
+ if opt == -99 {
r_builtin_help();
return EX_USAGE;
}
@@ -202,8 +196,8 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
}
list = loptend;
// 如果是严格模式,就直接返回EXECUTION_FAILURE,命令结束。
- if restricted != 0 && flags & (FFLAG|DFLAG) != 0 {
- sh_restricted (0 as *mut c_char);
+ if restricted != 0 && flags & (FFLAG | DFLAG) != 0 {
+ sh_restricted(0 as *mut c_char);
return EXECUTION_FAILURE!();
}
@@ -213,11 +207,12 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
// 否则判断是否带-N
// 带则打印DISABLED的,不带—N则打印ENABLED的
if list.is_null() || flags & PFLAG != 0 {
- filter = if flags & AFLAG != 0 { ENABLED | DISABLED }
- else if flags & NFLAG != 0 {
+ filter = if flags & AFLAG != 0 {
+ ENABLED | DISABLED
+ } else if flags & NFLAG != 0 {
DISABLED
} else {
- ENABLED
+ ENABLED
};
if flags & SFLAG != 0 {
@@ -225,10 +220,9 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
}
list_some_builtins(filter);
-
} else if flags & FFLAG != 0 {
- // 如果不带-N或者参数不为空,那么判断-F.(bash源文件中判断HAVE_DLSYM,HAVE_DLOPEN两个宏存在)
- // -F后面需要加文件名,载入so,作为内建命令
+ // 如果不带-N或者参数不为空,那么判断-F.(bash源文件中判断HAVE_DLSYM,HAVE_DLOPEN两个宏存在)
+ // -F后面需要加文件名,载入so,作为内建命令
//判断是ENABLED还是DISABLED
filter = if flags & NFLAG != 0 {
@@ -244,12 +238,11 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
//载入so
result = dyn_load_builtin(list, filter, filename);
-
+
// 设置完成,bash源代码中判断PROGRAMMABLE_COMPLETION
set_itemlist_dirty(&mut it_builtins);
-
} else if flags & DFLAG != 0 {
- // 否则判断-D,-D含义是删除以 -f 选项加载的内建
+ // 否则判断-D,-D含义是删除以 -f 选项加载的内建
while !list.is_null() {
opt = dyn_unload_builtin((*(*list).word).word);
if opt == EXECUTION_FAILURE!() {
@@ -258,9 +251,8 @@ pub unsafe extern "C" fn r_enable_builtin(mut list: *mut WordList) -> i32 {
list = (*list).next;
}
set_itemlist_dirty(&mut it_builtins);
-
} else {
- // 不带-N -F -D,且选项不为空的其他
+ // 不带-N -F -D,且选项不为空的其他
while !list.is_null() {
opt = enable_shell_command((*(*list).word).word, flags & NFLAG);
if opt == EXECUTION_FAILURE!() {
@@ -278,26 +270,22 @@ unsafe extern "C" fn list_some_builtins(mut filter: libc::c_int) {
let mut i: i32 = 0;
while i < num_shell_builtins {
- let tmpIter =*shell_builtins.offset(i as isize);
- if !(tmpIter.function.is_none()||tmpIter.flags & BUILTIN_DELETED != 0)
- {
+ let tmpIter = *shell_builtins.offset(i as isize);
+ if !(tmpIter.function.is_none() || tmpIter.flags & BUILTIN_DELETED != 0) {
if !(filter & SPECIAL != 0
- && (*shell_builtins.offset(i as isize)).flags & SPECIAL_BUILTIN
- == 0)
+ && (*shell_builtins.offset(i as isize)).flags & SPECIAL_BUILTIN == 0)
{
if filter & ENABLED != 0
- && (*shell_builtins.offset(i as isize)).flags & BUILTIN_ENABLED
- != 0
+ && (*shell_builtins.offset(i as isize)).flags & BUILTIN_ENABLED != 0
{
- let name= unsafe{CStr::from_ptr((*shell_builtins.offset(i as isize)).name)};
+ let name = unsafe { CStr::from_ptr((*shell_builtins.offset(i as isize)).name) };
println!("enable {}", name.to_str().expect("name cannot trans"));
} else if filter & DISABLED != 0
- && (*shell_builtins.offset(i as isize)).flags
- & BUILTIN_ENABLED == 0 as libc::c_int
- {
- let name= unsafe{CStr::from_ptr((*shell_builtins.offset(i as isize)).name)};
- println!("enable -n {}", name.to_str().expect("name cannot trans"));
-
+ && (*shell_builtins.offset(i as isize)).flags & BUILTIN_ENABLED
+ == 0 as libc::c_int
+ {
+ let name = unsafe { CStr::from_ptr((*shell_builtins.offset(i as isize)).name) };
+ println!("enable -n {}", name.to_str().expect("name cannot trans"));
}
}
}
@@ -329,7 +317,7 @@ unsafe extern "C" fn enable_shell_command(
insert_empty_cmd(CStr::from_ptr(name).to_string_lossy().into_owned());
set_cmd_enable(CStr::from_ptr(name).to_string_lossy().into_owned(), true);
}
- }
+ }
set_itemlist_dirty(&mut it_enabled);
set_itemlist_dirty(&mut it_disabled);
return EXECUTION_SUCCESS!();
@@ -349,7 +337,7 @@ unsafe extern "C" fn dyn_load_builtin(
let mut struct_name: *mut libc::c_char = 0 as *mut libc::c_char;
let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
let mut funcname: *mut libc::c_char = 0 as *mut libc::c_char;
- let mut loadfunc: Option:: = None;
+ let mut loadfunc: Option = None;
let mut new_builtins: *mut *mut builtin = 0 as *mut *mut builtin;
let mut b: *mut builtin = 0 as *mut builtin;
let mut new_shell_builtins: *mut builtin = 0 as *mut builtin;
@@ -361,9 +349,8 @@ unsafe extern "C" fn dyn_load_builtin(
}
handle = 0 as *mut libc::c_void;
if absolute_program(filename) == 0 as libc::c_int {
- loadables_path = get_string_value(
- b"BASH_LOADABLES_PATH\0" as *const u8 as *const libc::c_char,
- );
+ loadables_path =
+ get_string_value(b"BASH_LOADABLES_PATH\0" as *const u8 as *const libc::c_char);
if !loadables_path.is_null() {
load_path = find_in_path(
filename,
@@ -384,8 +371,7 @@ unsafe extern "C" fn dyn_load_builtin(
builtin_error(
dcgettext(
0 as *const libc::c_char,
- b"cannot open shared object %s: %s\0" as *const u8
- as *const libc::c_char,
+ b"cannot open shared object %s: %s\0" as *const u8 as *const libc::c_char,
5 as libc::c_int,
),
name,
@@ -403,8 +389,7 @@ unsafe extern "C" fn dyn_load_builtin(
new += 1;
}
new_builtins = xmalloc(
- (new as libc::c_ulong)
- .wrapping_mul(::std::mem::size_of::<*mut builtin>() as libc::c_ulong),
+ (new as libc::c_ulong).wrapping_mul(::std::mem::size_of::<*mut builtin>() as libc::c_ulong),
) as *mut *mut builtin;
let mut current_block_57: u64;
new = 0 as libc::c_int;
@@ -425,8 +410,7 @@ unsafe extern "C" fn dyn_load_builtin(
builtin_error(
dcgettext(
0 as *const libc::c_char,
- b"cannot find %s in shared object %s: %s\0" as *const u8
- as *const libc::c_char,
+ b"cannot find %s in shared object %s: %s\0" as *const u8 as *const libc::c_char,
5 as libc::c_int,
),
struct_name,
@@ -441,9 +425,7 @@ unsafe extern "C" fn dyn_load_builtin(
funcname = xrealloc(
struct_name as *mut libc::c_void,
(size as libc::c_ulong)
- .wrapping_add(
- ::std::mem::size_of::<[libc::c_char; 14]>() as libc::c_ulong,
- )
+ .wrapping_add(::std::mem::size_of::<[libc::c_char; 14]>() as libc::c_ulong)
.wrapping_add(1 as libc::c_int as libc::c_ulong),
) as *mut libc::c_char;
strcpy(funcname, name);
@@ -451,10 +433,9 @@ unsafe extern "C" fn dyn_load_builtin(
funcname.offset(size as isize),
b"_builtin_load\0" as *const u8 as *const libc::c_char,
);
- loadfunc = ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(dlsym(handle, funcname));
+ loadfunc = ::std::mem::transmute::<*mut libc::c_void, Option>(dlsym(
+ handle, funcname,
+ ));
if loadfunc.is_some() {
if !old_builtin.is_null()
&& (*old_builtin).flags & 0x4 as libc::c_int == 0 as libc::c_int
@@ -475,8 +456,8 @@ unsafe extern "C" fn dyn_load_builtin(
builtin_error(
dcgettext(
0 as *const libc::c_char,
- b"load function for %s returns failure (%d): not loaded\0"
- as *const u8 as *const libc::c_char,
+ b"load function for %s returns failure (%d): not loaded\0" as *const u8
+ as *const libc::c_char,
5 as libc::c_int,
),
name,
@@ -505,8 +486,7 @@ unsafe extern "C" fn dyn_load_builtin(
libc::memcpy(
old_builtin as *mut libc::c_char as *mut libc::c_void,
b as *mut libc::c_char as *const libc::c_void,
- ::std::mem::size_of::() as libc::c_ulong
- as libc::size_t,
+ ::std::mem::size_of::() as libc::c_ulong as libc::size_t,
);
} else {
let fresh1 = new;
@@ -542,8 +522,7 @@ unsafe extern "C" fn dyn_load_builtin(
libc::memcpy(
&mut *new_shell_builtins.offset((num_shell_builtins + replaced) as isize)
as *mut builtin as *mut libc::c_char as *mut libc::c_void,
- *new_builtins.offset(replaced as isize) as *mut libc::c_char
- as *const libc::c_void,
+ *new_builtins.offset(replaced as isize) as *mut libc::c_char as *const libc::c_void,
::std::mem::size_of::() as libc::c_ulong as libc::size_t,
);
replaced += 1;
@@ -575,14 +554,13 @@ unsafe extern "C" fn delete_builtin(mut b: *mut builtin) {
libc::memcpy(
new_shell_builtins as *mut libc::c_char as *mut libc::c_void,
shell_builtins as *mut libc::c_char as *const libc::c_void,
- (ind as libc::c_ulong)
- .wrapping_mul(::std::mem::size_of::() as libc::c_ulong)
+ (ind as libc::c_ulong).wrapping_mul(::std::mem::size_of::() as libc::c_ulong)
as libc::size_t,
);
}
libc::memcpy(
- &mut *new_shell_builtins.offset(ind as isize) as *mut builtin
- as *mut libc::c_char as *mut libc::c_void,
+ &mut *new_shell_builtins.offset(ind as isize) as *mut builtin as *mut libc::c_char
+ as *mut libc::c_void,
&mut *shell_builtins.offset((ind + 1 as libc::c_int) as isize) as *mut builtin
as *mut libc::c_char as *const libc::c_void,
((num_shell_builtins - ind) as libc::c_ulong)
@@ -602,7 +580,7 @@ unsafe extern "C" fn dyn_unload_builtin(mut name: *mut libc::c_char) -> libc::c_
let mut b: *mut builtin = 0 as *mut builtin;
let mut handle: *mut libc::c_void = 0 as *mut libc::c_void;
let mut funcname: *mut libc::c_char = 0 as *mut libc::c_char;
- let mut unloadfunc: Option:: = None;
+ let mut unloadfunc: Option = None;
let mut ref_0: libc::c_int = 0;
let mut i: libc::c_int = 0;
let mut size: libc::c_int = 0;
@@ -642,13 +620,13 @@ unsafe extern "C" fn dyn_unload_builtin(mut name: *mut libc::c_char) -> libc::c_
funcname.offset(size as isize),
b"_builtin_unload\0" as *const u8 as *const libc::c_char,
);
- unloadfunc = ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(dlsym(handle, funcname));
+ unloadfunc = ::std::mem::transmute::<*mut libc::c_void, Option>(dlsym(
+ handle, funcname,
+ ));
if unloadfunc.is_some() {
- (Some(unloadfunc.expect("non-null function pointer")))
- .expect("no-null function pointer")(name);
+ (Some(unloadfunc.expect("non-null function pointer"))).expect("no-null function pointer")(
+ name,
+ );
}
free(funcname as *mut libc::c_void);
if ref_0 == 1 as libc::c_int && local_dlclose(handle) != 0 as libc::c_int {
diff --git a/bash-5.1/builtins_rust/eval/src/lib.rs b/bash-5.1/builtins_rust/eval/src/lib.rs
index bde54e670598a6e569c7f56ae70be810f3b1f3ef..398a6fc381cebdc63bd644d356e319e28faeaa3f 100644
--- a/bash-5.1/builtins_rust/eval/src/lib.rs
+++ b/bash-5.1/builtins_rust/eval/src/lib.rs
@@ -1,34 +1,33 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate rcommon;
-use libc::{c_char,c_int};
-use std::ffi::{CString};
-use rcommon::{r_no_options};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
-use rhelp::r_builtin_help;
+use libc::c_char;
+use rcommon::r_no_options;
+use rcommon::{WordList, EXECUTION_SUCCESS, EX_USAGE};
+use std::ffi::CString;
#[macro_export]
macro_rules! SEVAL_NOHIST {
- () => {0x004}
+ () => {
+ 0x004
+ };
}
-
extern "C" {
- static loptend:*mut WordList;
+ static loptend: *mut WordList;
// fn no_options(list:*mut WordList)->i32;
- fn evalstring(string:*mut c_char,from_file:*const c_char,flag:i32)->i32;
- fn string_list(list:*mut WordList)->*mut c_char;
+ fn evalstring(string: *mut c_char, from_file: *const c_char, flag: i32) -> i32;
+ fn string_list(list: *mut WordList) -> *mut c_char;
}
#[no_mangle]
-pub extern "C" fn r_eval_builtin(mut list:*mut WordList)->i32{
-
- unsafe{
- if r_no_options(list) != 0{
+pub extern "C" fn r_eval_builtin(mut list: *mut WordList) -> i32 {
+ unsafe {
+ if r_no_options(list) != 0 {
return EX_USAGE;
}
@@ -37,13 +36,11 @@ pub extern "C" fn r_eval_builtin(mut list:*mut WordList)->i32{
if !list.is_null() {
let c_str = CString::new("eval").unwrap();
let c_ptr = c_str.as_ptr();
- return evalstring(string_list(list),c_ptr,SEVAL_NOHIST!());
- }
- else{
+ return evalstring(string_list(list), c_ptr, SEVAL_NOHIST!());
+ } else {
return EXECUTION_SUCCESS!();
}
}
-
}
#[cfg(test)]
diff --git a/bash-5.1/builtins_rust/exec/src/lib.rs b/bash-5.1/builtins_rust/exec/src/lib.rs
index cf21ea48a733e0b08fbb091742abce27da78a3ef..4edefab0f30787f2dd5b1a1f21f05105daa8fcd9 100644
--- a/bash-5.1/builtins_rust/exec/src/lib.rs
+++ b/bash-5.1/builtins_rust/exec/src/lib.rs
@@ -1,33 +1,36 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate nix;
extern crate rcommon;
-use libc::{c_char,c_int, strlen, strcpy, size_t, c_void, free};
-use std::ffi::{CString,CStr};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage, r_savestring};
+use libc::{c_char, c_int, c_void, free, size_t, strcpy, strlen};
use nix::errno::errno;
use rcommon::r_sh_restricted;
+use rcommon::{
+ r_builtin_usage, r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS,
+ EX_NOEXEC, EX_NOTFOUND, EX_USAGE, SUBSHELL_PAREN,
+};
use rhelp::r_builtin_help;
+use std::ffi::{CStr, CString};
#[repr(C)]
-struct redirect{
- next:*mut redirect,
- redirector:REDIRECTEE,
- rflags:i32,
- flags:i32,
- insturction:r_instruction,
- redirectee:REDIRECTEE,
- here_doc_eof:*mut c_char,
+struct redirect {
+ next: *mut redirect,
+ redirector: REDIRECTEE,
+ rflags: i32,
+ flags: i32,
+ insturction: r_instruction,
+ redirectee: REDIRECTEE,
+ here_doc_eof: *mut c_char,
}
type REDIRECT = redirect;
-#[repr (C)]
+#[repr(C)]
union REDIRECTEE {
- dest:i32,
- filename:*mut WordDesc,
+ dest: i32,
+ filename: *mut WordDesc,
}
pub type r_instruction = libc::c_uint;
@@ -52,109 +55,111 @@ pub const r_inputa_direction: r_instruction = 2;
pub const r_input_direction: r_instruction = 1;
pub const r_output_direction: r_instruction = 0;
-
#[macro_export]
macro_rules! FREE {
($s:expr) => {
- if ($s) != std::ptr::null_mut(){
+ if ($s) != std::ptr::null_mut() {
free($s);
}
- }
+ };
}
extern "C" {
// static errno:i32;
- static mut exec_argv0:*mut c_char;
- static list_optarg:*mut c_char;
- static loptend:*mut WordList;
- static mut redirection_undo_list:*mut REDIRECT;
- static restricted:i32;
+ static mut exec_argv0: *mut c_char;
+ static list_optarg: *mut c_char;
+ static loptend: *mut WordList;
+ static mut redirection_undo_list: *mut REDIRECT;
+ static restricted: i32;
// static comsub_ignore_return:i32;
- static export_env:*mut *mut c_char;
- static interactive_shell:i32;
- static subshell_environment:i32;
- static job_control:i32;
- static interactive:i32;
- static default_buffered_input:i32;
- static no_exit_on_failed_exec:i32;
- fn xmalloc(n:size_t)->*mut c_void;
+ static export_env: *mut *mut c_char;
+ static interactive_shell: i32;
+ static subshell_environment: i32;
+ static job_control: i32;
+ static interactive: i32;
+ static default_buffered_input: i32;
+ static no_exit_on_failed_exec: i32;
+ fn xmalloc(n: size_t) -> *mut c_void;
fn reset_internal_getopt();
- fn internal_getopt(list:*mut WordList,opts:*mut c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
// fn builtin_usage();
- fn dispose_redirects(list:*mut REDIRECT);
+ fn dispose_redirects(list: *mut REDIRECT);
// fn sh_restricted(s:*mut c_char);
- fn strvec_from_word_list(list:*mut WordList,alloc:i32,starting_index:i32,ip:*mut i32)->*mut *mut c_char;
- fn absolute_program(string:*const c_char)->i32;
- fn search_for_command(pathname:*const c_char,flags:i32)->*mut c_char;
- fn file_isdir(f:*const c_char)->i32;
- fn builtin_error(format:*const c_char,...);
- fn strerror(e:i32)->*mut c_char;
- fn sh_notfound(s:*mut c_char);
- fn full_pathname(file:*mut c_char)->*mut c_char;
- fn adjust_shell_level(change:i32);
- fn strvec_create(n:i32)->*mut *mut c_char;
+ fn strvec_from_word_list(
+ list: *mut WordList,
+ alloc: i32,
+ starting_index: i32,
+ ip: *mut i32,
+ ) -> *mut *mut c_char;
+ fn absolute_program(string: *const c_char) -> i32;
+ fn search_for_command(pathname: *const c_char, flags: i32) -> *mut c_char;
+ fn file_isdir(f: *const c_char) -> i32;
+ fn builtin_error(format: *const c_char, ...);
+ fn strerror(e: i32) -> *mut c_char;
+ fn sh_notfound(s: *mut c_char);
+ fn full_pathname(file: *mut c_char) -> *mut c_char;
+ fn adjust_shell_level(change: i32);
+ fn strvec_create(n: i32) -> *mut *mut c_char;
fn maybe_make_export_env();
- fn maybe_save_shell_history()->i32;
+ fn maybe_save_shell_history() -> i32;
fn restore_original_signals();
fn end_job_control();
fn default_tty_job_signals();
- fn sync_buffered_stream(bfd:i32)->i32;
- fn shell_execve(command:*mut c_char,args:*mut *mut c_char,env:*mut *mut c_char)->i32;
- fn executable_file(file:*const c_char)->i32;
- fn file_error(filename:*mut c_char);
- fn exit_shell(s:i32);
- fn strvec_dispose(array:*mut *mut c_char);
+ fn sync_buffered_stream(bfd: i32) -> i32;
+ fn shell_execve(command: *mut c_char, args: *mut *mut c_char, env: *mut *mut c_char) -> i32;
+ fn executable_file(file: *const c_char) -> i32;
+ fn file_error(filename: *mut c_char);
+ fn exit_shell(s: i32);
+ fn strvec_dispose(array: *mut *mut c_char);
fn initialize_traps();
- fn initialize_signals(reinit:i32);
+ fn initialize_signals(reinit: i32);
fn restart_job_control();
}
/* If the user wants this to look like a login shell, then
- prepend a `-' onto NAME and return the new name. */
+prepend a `-' onto NAME and return the new name. */
#[no_mangle]
-extern "C" fn r_mkdashname(name:*mut c_char)->*mut c_char{
- let ret:*mut c_char;
+extern "C" fn r_mkdashname(name: *mut c_char) -> *mut c_char {
+ let ret: *mut c_char;
- unsafe{
+ unsafe {
ret = xmalloc(2 + strlen(name)) as *mut c_char;
*ret.offset(0) = '-' as libc::c_char;
strcpy(ret.offset(1), name);
return ret;
}
-
-}
-
+}
#[no_mangle]
-pub extern "C" fn r_exec_builtin(mut list:*mut WordList)->i32{
- let mut exit_value ;
- let mut cleanenv:i32 = 0;
- let mut login:i32 = 0;
- let mut opt:i32;
- let mut orig_job_control:i32 = 0;
- let mut argv0:*mut c_char = std::ptr::null_mut() as *mut c_char;
- let mut command:*mut c_char;
- let mut args:*mut *mut c_char;
- let mut env:*mut *mut c_char;
- let newname:*mut c_char;
- let com2:*mut c_char;
-
- unsafe{
+pub extern "C" fn r_exec_builtin(mut list: *mut WordList) -> i32 {
+ let mut exit_value;
+ let mut cleanenv: i32 = 0;
+ let mut login: i32 = 0;
+ let mut opt: i32;
+ let mut orig_job_control: i32 = 0;
+ let mut argv0: *mut c_char = std::ptr::null_mut() as *mut c_char;
+ let mut command: *mut c_char;
+ let mut args: *mut *mut c_char;
+ let mut env: *mut *mut c_char;
+ let newname: *mut c_char;
+ let com2: *mut c_char;
+
+ unsafe {
exec_argv0 = std::ptr::null_mut() as *mut c_char;
reset_internal_getopt();
-
- loop{
+
+ loop {
let c_str = CString::new("cla:").unwrap();
- opt = internal_getopt(list,c_str.as_ptr() as *mut c_char);
- while opt != -1{
+ opt = internal_getopt(list, c_str.as_ptr() as *mut c_char);
+ while opt != -1 {
let optu8 = opt as u8;
let opt_char = char::from(optu8);
- match opt_char{
+ match opt_char {
'c' => cleanenv = 1,
'l' => login = 1,
'a' => argv0 = list_optarg,
- _ => {
+ _ => {
if opt == -99 {
r_builtin_help();
return EX_USAGE;
@@ -163,169 +168,163 @@ pub extern "C" fn r_exec_builtin(mut list:*mut WordList)->i32{
return EX_USAGE;
}
}
-
- opt = internal_getopt(list,c_str.as_ptr() as *mut c_char);
+
+ opt = internal_getopt(list, c_str.as_ptr() as *mut c_char);
}
-
+
list = loptend;
-
+
/* First, let the redirections remain. */
dispose_redirects(redirection_undo_list);
redirection_undo_list = std::ptr::null_mut() as *mut REDIRECT;
-
- if list.is_null(){
+
+ if list.is_null() {
return EXECUTION_SUCCESS!();
}
- if restricted != 0{ //限制性shell
+ if restricted != 0 {
+ //限制性shell
// sh_restricted(std::ptr::null_mut() as *mut c_char);
r_sh_restricted(std::ptr::null_mut() as *mut c_char);
return EXECUTION_FAILURE!();
}
-
- args = strvec_from_word_list(list,1,0,0 as *mut c_int); //这个指针这样写不清楚可不可以
+
+ args = strvec_from_word_list(list, 1, 0, 0 as *mut c_int); //这个指针这样写不清楚可不可以
env = 0 as *mut *mut c_char;
-
+
/* A command with a slash anywhere in its name is not looked up in $PATH. */
- if absolute_program(*args.offset(0)) != 0{ //命令给的绝对路径,或者执行脚本
+ if absolute_program(*args.offset(0)) != 0 {
+ //命令给的绝对路径,或者执行脚本
command = (*args).offset(0);
+ } else {
+ //exec后直接给命令
+ command = search_for_command(*args.offset(0), 1);
+ println!("command:{}", CStr::from_ptr(command).to_str().unwrap());
}
- else { //exec后直接给命令
- command = search_for_command(*args.offset(0),1);
- println!("command:{}",CStr::from_ptr(command).to_str().unwrap());
- }
-
- if command.is_null(){
- if file_isdir(*args.offset(0)) != 0{
+
+ if command.is_null() {
+ if file_isdir(*args.offset(0)) != 0 {
let c_str = CString::new("%s: cannot execute: %s").unwrap();
let c_ptr = c_str.as_ptr();
- builtin_error(c_ptr,*args.offset(0),strerror(errno()));
+ builtin_error(c_ptr, *args.offset(0), strerror(errno()));
exit_value = EX_NOEXEC;
- }
- else{
+ } else {
sh_notfound(*args.offset(0));
exit_value = EX_NOTFOUND;
}
//goto failed_exec;
break;
}
-
+
com2 = full_pathname(command);
- if !com2.is_null(){
- if command != *args.offset(0){
+ if !com2.is_null() {
+ if command != *args.offset(0) {
free(command as *mut c_void);
}
command = com2;
}
-
- if !argv0.is_null(){ //exec有-a参数
+
+ if !argv0.is_null() {
+ //exec有-a参数
free(*args.offset(0) as *mut c_void);
- if login != 0{
+ if login != 0 {
*args.offset(0) = r_mkdashname(argv0);
- }
- else {
+ } else {
*args.offset(0) = r_savestring(argv0);
}
exec_argv0 = r_savestring(*args.offset(0));
- }
- else if login != 0{
+ } else if login != 0 {
newname = r_mkdashname(*args.offset(0));
free(*args.offset(0) as *mut c_void);
*args.offset(0) = newname;
}
-
+
/* Decrement SHLVL by 1 so a new shell started here has the same value,
- preserving the appearance. After we do that, we need to change the
- exported environment to include the new value. If we've already forked
- and are in a subshell, we don't want to decrement the shell level,
- since we are `increasing' the level */
-
- if cleanenv == 0 && (subshell_environment & SUBSHELL_PAREN!() == 0){
+ preserving the appearance. After we do that, we need to change the
+ exported environment to include the new value. If we've already forked
+ and are in a subshell, we don't want to decrement the shell level,
+ since we are `increasing' the level */
+
+ if cleanenv == 0 && (subshell_environment & SUBSHELL_PAREN!() == 0) {
adjust_shell_level(-1);
}
-
- if cleanenv != 0{
+
+ if cleanenv != 0 {
env = strvec_create(1);
*env.offset(0) = 0 as *mut c_char;
- }
- else{
+ } else {
maybe_make_export_env();
env = export_env;
}
-
- if interactive_shell !=0 && subshell_environment == 0{
+
+ if interactive_shell != 0 && subshell_environment == 0 {
maybe_save_shell_history();
}
-
+
restore_original_signals();
-
+
orig_job_control = job_control;
- if subshell_environment == 0{
+ if subshell_environment == 0 {
end_job_control();
}
- if interactive != 0 || job_control != 0{
+ if interactive != 0 || job_control != 0 {
default_tty_job_signals();
}
-
- if default_buffered_input >= 0{
+
+ if default_buffered_input >= 0 {
sync_buffered_stream(default_buffered_input);
}
-
- exit_value = shell_execve(command,args,env);
-
+
+ exit_value = shell_execve(command, args, env);
+
/* We have to set this to NULL because shell_execve has called realloc()
- to stuff more items at the front of the array, which may have caused
- the memory to be freed by realloc(). We don't want to free it twice. */
-
+ to stuff more items at the front of the array, which may have caused
+ the memory to be freed by realloc(). We don't want to free it twice. */
+
args = std::ptr::null_mut() as *mut *mut c_char;
-
+
if cleanenv == 0 {
adjust_shell_level(1);
}
-
- if exit_value == EX_NOTFOUND{
+
+ if exit_value == EX_NOTFOUND {
//goto failed_exec;
break;
- }
- else if executable_file(command) == 0{
+ } else if executable_file(command) == 0 {
let c_str = CString::new("%s: cannot execute: %s").unwrap();
let c_ptr = c_str.as_ptr();
- builtin_error(c_ptr,command,strerror(errno()));
+ builtin_error(c_ptr, command, strerror(errno()));
exit_value = EX_NOEXEC;
- }
- else{
+ } else {
file_error(command);
- }
-
+ }
+
//跳出loop循环,只执行一次loop
break;
}
-
//fialed_exec
FREE!(command as *mut c_void);
-
- if subshell_environment != 0 || interactive == 0 && no_exit_on_failed_exec ==0{
+
+ if subshell_environment != 0 || interactive == 0 && no_exit_on_failed_exec == 0 {
exit_shell(exit_value);
}
- if !args.is_null(){
+ if !args.is_null() {
strvec_dispose(args);
}
- if !env.is_null() && env != export_env{
+ if !env.is_null() && env != export_env {
strvec_dispose(env);
- }
+ }
initialize_traps();
initialize_signals(1);
- if orig_job_control != 0{
+ if orig_job_control != 0 {
restart_job_control();
}
return exit_value;
}
}
-
-
diff --git a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs
index f22160e5e5d73b9ecf0f31326441fdfc558079ae..5b94acddaf8894fa1bbc3eb8cc2a72e43d696857 100644
--- a/bash-5.1/builtins_rust/exec_cmd/src/lib.rs
+++ b/bash-5.1/builtins_rust/exec_cmd/src/lib.rs
@@ -1,41 +1,41 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use rcommon::WordList;
-use ralias::{r_alias_builtin,r_unalias_builtin};
+use ralias::{r_alias_builtin, r_unalias_builtin};
use rbind::r_bind_builtin;
-use rbreak::{r_break_builtin,r_continue_builtin};
+use rbreak::{r_break_builtin, r_continue_builtin};
use rbuiltin::r_builtin_builtin;
use rcaller::r_caller_builtin;
-use rcd::{r_cd_builtin,r_pwd_builtin};
+use rcd::{r_cd_builtin, r_pwd_builtin};
+use rcommon::WordList;
//use rcmd::r_cmd_builtin;
-use rcolon::{r_colon_builtin,r_false_builtin};
use command::r_command_builtin;
+use rcolon::{r_colon_builtin, r_false_builtin};
//use rcommon ::r__builtin;
-use rcomplete::{r_complete_builtin,r_compgen_builtin,r_compopt_builtin};
-use rdeclare::{r_declare_builtin,r_local_builtin};
+use rcomplete::{r_compgen_builtin, r_complete_builtin, r_compopt_builtin};
+use rdeclare::{r_declare_builtin, r_local_builtin};
use recho::r_echo_builtin;
use renable::r_enable_builtin;
use reval::r_eval_builtin;
use rexec::r_exec_builtin;
-use rexit::{r_exit_builtin,r_logout_builtin};
+use rexit::{r_exit_builtin, r_logout_builtin};
use rfc::r_fc_builtin;
-use rfg_bg::{r_fg_builtin,r_bg_builtin};
+use rfg_bg::{r_bg_builtin, r_fg_builtin};
use rgetopts::r_getopts_builtin;
use rhash::r_hash_builtin;
use rhelp::r_help_builtin;
use rhistory::r_history_builtin;
-use rjobs::r_jobs_builtin;
use rjobs::r_disown_builtin;
+use rjobs::r_jobs_builtin;
use rkill::r_kill_builtin;
+use rlet::r_let_builtin;
use rmapfile::r_mapfile_builtin;
use rprintf::r_printf_builtin;
-use rpushd::{r_pushd_builtin,r_dirs_builtin,r_popd_builtin};
+use rpushd::{r_dirs_builtin, r_popd_builtin, r_pushd_builtin};
use rread::r_read_builtin;
-use rlet::r_let_builtin;
use rreturn::r_return_builtin;
-use rset::{r_set_builtin,r_unset_builtin};
-use rsetattr::{r_export_builtin,r_readonly_builtin};
+use rset::{r_set_builtin, r_unset_builtin};
+use rsetattr::{r_export_builtin, r_readonly_builtin};
use rshift::r_shift_builtin;
use rshopt::r_shopt_builtin;
use rsource::r_source_builtin;
@@ -47,9 +47,6 @@ use rtype::r_type_builtin;
use rulimit::r_ulimit_builtin;
use rumask::r_umask_builtin;
use rwait::r_wait_builtin;
-use std::ffi::CStr;
-use std::ffi::CString;
-use libc::{strcmp};
enum CMDType {
AliasCmd,
@@ -110,415 +107,388 @@ enum CMDType {
UlimitCmd,
UmaskCmd,
WaitCmd,
- DisownCmd
+ DisownCmd,
}
- struct AliasComand ;
- impl CommandExec for AliasComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_alias_builtin(list)
- }
+struct AliasComand;
+impl CommandExec for AliasComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_alias_builtin(list) }
}
- }
- struct UnAliasComand ;
- impl CommandExec for UnAliasComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_unalias_builtin(list)
- }
+}
+struct UnAliasComand;
+impl CommandExec for UnAliasComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_unalias_builtin(list) }
}
- }
+}
- struct BindComand;
- impl CommandExec for BindComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct BindComand;
+impl CommandExec for BindComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_bind_builtin(list)
}
}
- struct BreakComand;
- impl CommandExec for BreakComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct BreakComand;
+impl CommandExec for BreakComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_break_builtin(list)
}
}
struct ContinueComand;
- impl CommandExec for ContinueComand{
- fn excute(&self,list : *mut WordList)-> i32{
+impl CommandExec for ContinueComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_continue_builtin(list)
}
}
- struct BuiltinComand;
- impl CommandExec for BuiltinComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct BuiltinComand;
+impl CommandExec for BuiltinComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_builtin_builtin(list)
}
}
- struct CallerComand;
- impl CommandExec for CallerComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct CallerComand;
+impl CommandExec for CallerComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_caller_builtin(list)
}
}
- struct CdComand;
- impl CommandExec for CdComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct CdComand;
+impl CommandExec for CdComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_cd_builtin(list)
}
}
struct PwdComand;
-impl CommandExec for PwdComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_pwd_builtin(list)
- }
-}
- struct ColonComand;
- impl CommandExec for ColonComand{
- fn excute(&self,list :*mut WordList)-> i32{
+impl CommandExec for PwdComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_pwd_builtin(list)
+ }
+}
+struct ColonComand;
+impl CommandExec for ColonComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_colon_builtin(list)
- // 0
+ // 0
}
}
struct FalseComand;
-impl CommandExec for FalseComand{
- fn excute(&self,list :*mut WordList)-> i32{
- r_false_builtin(list)
- // 0
- }
-}
- struct CommandComand;
- impl CommandExec for CommandComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_command_builtin(list)
- }
-
+impl CommandExec for FalseComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_false_builtin(list)
+ // 0
}
}
- struct CommonComand;
- impl CommandExec for CommonComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct CommandComand;
+impl CommandExec for CommandComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_command_builtin(list) }
+ }
+}
+struct CommonComand;
+impl CommandExec for CommonComand {
+ fn excute(&self, _list: *mut WordList) -> i32 {
0
}
}
- struct CompleteComand;
- impl CommandExec for CompleteComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct CompleteComand;
+impl CommandExec for CompleteComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_complete_builtin(list)
}
}
-
-struct CompgenCommand;
-impl CommandExec for CompgenCommand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_compgen_builtin(list)
- }
+struct CompgenCommand;
+impl CommandExec for CompgenCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_compgen_builtin(list)
+ }
}
-struct CompoptCommand;
-impl CommandExec for CompoptCommand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_compopt_builtin(list)
- }
-}
- struct DeclareComand;
- impl CommandExec for DeclareComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct CompoptCommand;
+impl CommandExec for CompoptCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_compopt_builtin(list)
+ }
+}
+struct DeclareComand;
+impl CommandExec for DeclareComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_declare_builtin(list)
}
}
struct LocalComand;
- impl CommandExec for LocalComand{
- fn excute(&self,list : *mut WordList)-> i32{
+impl CommandExec for LocalComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_local_builtin(list)
}
}
- struct EchoComand;
- impl CommandExec for EchoComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct EchoComand;
+impl CommandExec for EchoComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_echo_builtin(list)
}
}
- struct EnableComand;
- impl CommandExec for EnableComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_enable_builtin(list)
- }
+struct EnableComand;
+impl CommandExec for EnableComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_enable_builtin(list) }
}
}
- struct EvalComand;
- impl CommandExec for EvalComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct EvalComand;
+impl CommandExec for EvalComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_eval_builtin(list)
}
}
- struct ExecComand;
- impl CommandExec for ExecComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct ExecComand;
+impl CommandExec for ExecComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_exec_builtin(list)
}
}
- struct ExitComand;
- impl CommandExec for ExitComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct ExitComand;
+impl CommandExec for ExitComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_exit_builtin(list)
}
}
struct LogoutCommand;
-impl CommandExec for LogoutCommand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_logout_builtin(list)
- }
-}
- struct FcComand;
- impl CommandExec for FcComand{
- fn excute(&self,list : *mut WordList)-> i32{
+impl CommandExec for LogoutCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_logout_builtin(list)
+ }
+}
+struct FcComand;
+impl CommandExec for FcComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_fc_builtin(list)
}
}
- struct FgComand;
- impl CommandExec for FgComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct FgComand;
+impl CommandExec for FgComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_fg_builtin(list)
}
}
struct BgComand;
-impl CommandExec for BgComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_bg_builtin(list)
- }
-}
- struct GetoptsComand;
- impl CommandExec for GetoptsComand{
- fn excute(&self,list : *mut WordList)-> i32{
+impl CommandExec for BgComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_bg_builtin(list)
+ }
+}
+struct GetoptsComand;
+impl CommandExec for GetoptsComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_getopts_builtin(list)
}
}
- struct HashComand;
- impl CommandExec for HashComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_hash_builtin(list)
+struct HashComand;
+impl CommandExec for HashComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_hash_builtin(list)
}
}
- struct HelpComand;
- impl CommandExec for HelpComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct HelpComand;
+impl CommandExec for HelpComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_help_builtin(list)
}
}
- struct HistoryComand;
- impl CommandExec for HistoryComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct HistoryComand;
+impl CommandExec for HistoryComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_history_builtin(list)
}
}
- struct JobsComand;
- impl CommandExec for JobsComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct JobsComand;
+impl CommandExec for JobsComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_jobs_builtin(list)
}
}
- struct KillComand;
- impl CommandExec for KillComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct KillComand;
+impl CommandExec for KillComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_kill_builtin(list)
}
}
- struct LetComand;
- impl CommandExec for LetComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct LetComand;
+impl CommandExec for LetComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_let_builtin(list)
}
}
- struct MapfileComand;
- impl CommandExec for MapfileComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct MapfileComand;
+impl CommandExec for MapfileComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_mapfile_builtin(list)
}
}
- struct PrintfComand;
- impl CommandExec for PrintfComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct PrintfComand;
+impl CommandExec for PrintfComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_printf_builtin(list)
}
}
- struct PushdCommand;
- impl CommandExec for PushdCommand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct PushdCommand;
+impl CommandExec for PushdCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_pushd_builtin(list)
}
}
struct PopdComand;
-impl CommandExec for PopdComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_popd_builtin(list)
- }
+impl CommandExec for PopdComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_popd_builtin(list)
+ }
}
struct DirsCommand;
-impl CommandExec for DirsCommand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_dirs_builtin(list)
- }
-}
- struct ReadComand;
- impl CommandExec for ReadComand{
- fn excute(&self,list : *mut WordList)-> i32{
+impl CommandExec for DirsCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_dirs_builtin(list)
+ }
+}
+struct ReadComand;
+impl CommandExec for ReadComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_read_builtin(list)
}
}
- struct ReservedComand;
- impl CommandExec for ReservedComand{
- fn excute(&self,list : *mut WordList)-> i32{
- // r_reserve_builtin(list)
- 0
+struct ReservedComand;
+impl CommandExec for ReservedComand {
+ fn excute(&self, _list: *mut WordList) -> i32 {
+ // r_reserve_builtin(list)
+ 0
}
}
- struct ReturnComand;
- impl CommandExec for ReturnComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct ReturnComand;
+impl CommandExec for ReturnComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_return_builtin(list)
}
}
- struct SetattrComand;
- impl CommandExec for SetattrComand{
- fn excute(&self,list : *mut WordList)-> i32{
- //r_setattr_builtin(list);
- /*unkown enter which func */
- 0
- }
-
+struct SetattrComand;
+impl CommandExec for SetattrComand {
+ fn excute(&self, _list: *mut WordList) -> i32 {
+ //r_setattr_builtin(list);
+ /*unkown enter which func */
+ 0
+ }
}
struct ExportComand;
-impl CommandExec for ExportComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_export_builtin(list)
- }
-
+impl CommandExec for ExportComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_export_builtin(list)
+ }
}
struct ReadonlyComand;
-impl CommandExec for ReadonlyComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_readonly_builtin(list)
- }
-
+impl CommandExec for ReadonlyComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_readonly_builtin(list)
+ }
}
- struct SetComand;
- impl CommandExec for SetComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct SetComand;
+impl CommandExec for SetComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_set_builtin(list)
}
-
}
struct UnSetComand;
-impl CommandExec for UnSetComand{
- fn excute(&self,list : *mut WordList)-> i32{
- r_unset_builtin(list)
- }
-
+impl CommandExec for UnSetComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ r_unset_builtin(list)
+ }
}
- struct ShiftComand;
- impl CommandExec for ShiftComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct ShiftComand;
+impl CommandExec for ShiftComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_shift_builtin(list)
}
-}
- struct ShoptComand;
- impl CommandExec for ShoptComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_shopt_builtin(list)
- }
- }
-}
- struct SourceComand;
- impl CommandExec for SourceComand{
- fn excute(&self,list : *mut WordList)-> i32{
+}
+struct ShoptComand;
+impl CommandExec for ShoptComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_shopt_builtin(list) }
+ }
+}
+struct SourceComand;
+impl CommandExec for SourceComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_source_builtin(list)
}
}
- struct SuspendComand;
- impl CommandExec for SuspendComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct SuspendComand;
+impl CommandExec for SuspendComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_suspend_builtin(list)
}
}
- struct TestComand;
- impl CommandExec for TestComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct TestComand;
+impl CommandExec for TestComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_test_builtin(list)
}
}
- struct TimesComand;
- impl CommandExec for TimesComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct TimesComand;
+impl CommandExec for TimesComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_times_builtin(list)
}
}
- struct TrapComand;
- impl CommandExec for TrapComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct TrapComand;
+impl CommandExec for TrapComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_trap_builtin(list)
}
}
- struct TypeComand;
- impl CommandExec for TypeComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_type_builtin(list)
- }
-
+struct TypeComand;
+impl CommandExec for TypeComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_type_builtin(list) }
}
-
}
- struct UlimitComand;
- impl CommandExec for UlimitComand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_ulimit_builtin(list)
- }
+struct UlimitComand;
+impl CommandExec for UlimitComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_ulimit_builtin(list) }
}
-
}
- struct UmaskComand;
- impl CommandExec for UmaskComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct UmaskComand;
+impl CommandExec for UmaskComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_umask_builtin(list)
}
}
- struct WaitComand;
- impl CommandExec for WaitComand{
- fn excute(&self,list : *mut WordList)-> i32{
+struct WaitComand;
+impl CommandExec for WaitComand {
+ fn excute(&self, list: *mut WordList) -> i32 {
r_wait_builtin(list)
}
}
- struct DisownCommand ;
- impl CommandExec for DisownCommand{
- fn excute(&self,list : *mut WordList)-> i32{
- unsafe {
- r_disown_builtin(list)
- }
+struct DisownCommand;
+impl CommandExec for DisownCommand {
+ fn excute(&self, list: *mut WordList) -> i32 {
+ unsafe { r_disown_builtin(list) }
}
- }
+}
// 定义接口
pub trait CommandExec {
- fn excute(&self,list : *mut WordList) -> i32;
+ fn excute(&self, list: *mut WordList) -> i32;
}
-
// 工厂模式
trait Factory {
- fn make_product(&self, product_type : CMDType) ->Box;
+ fn make_product(&self, product_type: CMDType) -> Box;
}
struct SimpleFactory;
@@ -529,401 +499,455 @@ impl SimpleFactory {
}
impl Factory for SimpleFactory {
- fn make_product(&self, cmd_type : CMDType) -> Box {
+ fn make_product(&self, cmd_type: CMDType) -> Box {
match cmd_type {
- CMDType::AliasCmd => Box::new(
- AliasComand{}
- ) ,
- CMDType::UnAliasCmd => Box::new(
- UnAliasComand{}
- ) ,
- CMDType::BindCmd => Box::new(
- BindComand{}
- ),
- CMDType::BreakCmd => Box::new(
- BreakComand{}
- ) ,
- CMDType::ContinueCmd => Box::new(
- ContinueComand{}
- ) ,
- CMDType::BuiltinCmd => Box::new(
- BuiltinComand{}
- ),
- CMDType::CallerCmd => Box::new(
- CallerComand{}
- ),
- CMDType::CdCmd => Box::new(
- CdComand{}
- ),
- CMDType::PwdCmd => Box::new(
- PwdComand{}
- ),
- CMDType::ColonCmd => Box::new(
- ColonComand{}
- ),
- CMDType::FalseCmd => Box::new(
- FalseComand{}
- ),
- CMDType::CommandCmd => Box::new(
- CommandComand{}
- ),
- CMDType::CommonCmd => Box::new(
- CommonComand{}
- ),
- CMDType::CompleteCmd => Box::new(
- CompleteComand{}
- ),
- CMDType::CompoptCmd => Box::new(
- CompoptCommand{}
- ),
- CMDType::CompgenCmd => Box::new(
- CompgenCommand{}
- ),
- CMDType::DeclareCmd => Box::new(
- DeclareComand{}
- ),
- CMDType::LocalCmd => Box::new(
- LocalComand{}
- ),
- CMDType::EchoCmd => Box::new(
- EchoComand{}
- ),
- CMDType::EnableCmd => Box::new(
- EnableComand{}
- ),
- CMDType::EvalCmd => Box::new(
- EvalComand{}
- ),
- CMDType::ExecCmd => Box::new(
- ExecComand{}
- ),
- CMDType::ExitCmd => Box::new(
- ExitComand{}
- ),
- CMDType::LogoutCmd => Box::new(
- LogoutCommand{}
- ),
- CMDType::FcCmd => Box::new(
- FcComand{}
- ),
- CMDType::FgCmd => Box::new(
- FgComand{}
- ),
- CMDType::BgCmd => Box::new(
- BgComand{}
- ),
- CMDType::GetoptsCmd => Box::new(
- GetoptsComand{}
- ),
- CMDType::HashCmd => Box::new(
- HashComand{}
- ),
- CMDType::HelpCmd => Box::new(
- HelpComand{}
- ),
- CMDType::HistoryCmd => Box::new(
- HistoryComand{}
- ),
- CMDType::JobsCmd => Box::new(
- JobsComand{}
- ),
- CMDType::KillCmd => Box::new(
- KillComand{}
- ),
- CMDType::LetCmd => Box::new(
- LetComand{}
- ),
- CMDType::MapfileCmd => Box::new(
- MapfileComand{}
- ),
- CMDType::PrintfCmd => Box::new(
- PrintfComand{}
- ),
- CMDType::PushdCmd => Box::new(
- PushdCommand{}
- ),
- CMDType::DirsCmd => Box::new(
- DirsCommand{}
- ),
- CMDType::PopdCmd => Box::new(
- PopdComand{}
- ),
- CMDType::ReadCmd => Box::new(
- ReadComand{}
- ),
- CMDType::ReservedCmd => Box::new(
- ReservedComand{}
- ),
- CMDType::ReturnCmd => Box::new(
- ReturnComand{}
- ),
- CMDType::SetattrCmd => Box::new(
- SetattrComand{}
- ),
- CMDType::ExportCmd => Box::new(
- ExportComand{}
- ),
- CMDType::ReadonlyCmd => Box::new(
- ReadonlyComand{}
- ),
- CMDType::SetCmd => Box::new(
- SetComand{}
- ),
- CMDType::UnSetCmd => Box::new(
- UnSetComand{}
- ),
- CMDType::ShiftCmd => Box::new(
- ShiftComand{}
- ),
- CMDType::ShoptCmd => Box::new(
- ShoptComand{}
- ),
- CMDType::SourceCmd => Box::new(
- SourceComand{}
- ),
- CMDType::SuspendCmd => Box::new(
- SuspendComand{}
- ),
- CMDType::TestCmd => Box::new(
- TestComand{}
- ),
- CMDType::TimesCmd => Box::new(
- TimesComand{}
- ),
- CMDType::TrapCmd => Box::new(
- TrapComand{}
- ),
- CMDType::TypeCmd => Box::new(
- TypeComand{}
- ),
- CMDType::UlimitCmd => Box::new(
- UlimitComand{}
- ),
- CMDType::UmaskCmd => Box::new(
- UmaskComand{}
- ),
- CMDType::WaitCmd => Box::new(
- WaitComand{}
- ),
- CMDType::DisownCmd => Box::new(
- DisownCommand{}
- )
+ CMDType::AliasCmd => Box::new(AliasComand {}),
+ CMDType::UnAliasCmd => Box::new(UnAliasComand {}),
+ CMDType::BindCmd => Box::new(BindComand {}),
+ CMDType::BreakCmd => Box::new(BreakComand {}),
+ CMDType::ContinueCmd => Box::new(ContinueComand {}),
+ CMDType::BuiltinCmd => Box::new(BuiltinComand {}),
+ CMDType::CallerCmd => Box::new(CallerComand {}),
+ CMDType::CdCmd => Box::new(CdComand {}),
+ CMDType::PwdCmd => Box::new(PwdComand {}),
+ CMDType::ColonCmd => Box::new(ColonComand {}),
+ CMDType::FalseCmd => Box::new(FalseComand {}),
+ CMDType::CommandCmd => Box::new(CommandComand {}),
+ CMDType::CommonCmd => Box::new(CommonComand {}),
+ CMDType::CompleteCmd => Box::new(CompleteComand {}),
+ CMDType::CompoptCmd => Box::new(CompoptCommand {}),
+ CMDType::CompgenCmd => Box::new(CompgenCommand {}),
+ CMDType::DeclareCmd => Box::new(DeclareComand {}),
+ CMDType::LocalCmd => Box::new(LocalComand {}),
+ CMDType::EchoCmd => Box::new(EchoComand {}),
+ CMDType::EnableCmd => Box::new(EnableComand {}),
+ CMDType::EvalCmd => Box::new(EvalComand {}),
+ CMDType::ExecCmd => Box::new(ExecComand {}),
+ CMDType::ExitCmd => Box::new(ExitComand {}),
+ CMDType::LogoutCmd => Box::new(LogoutCommand {}),
+ CMDType::FcCmd => Box::new(FcComand {}),
+ CMDType::FgCmd => Box::new(FgComand {}),
+ CMDType::BgCmd => Box::new(BgComand {}),
+ CMDType::GetoptsCmd => Box::new(GetoptsComand {}),
+ CMDType::HashCmd => Box::new(HashComand {}),
+ CMDType::HelpCmd => Box::new(HelpComand {}),
+ CMDType::HistoryCmd => Box::new(HistoryComand {}),
+ CMDType::JobsCmd => Box::new(JobsComand {}),
+ CMDType::KillCmd => Box::new(KillComand {}),
+ CMDType::LetCmd => Box::new(LetComand {}),
+ CMDType::MapfileCmd => Box::new(MapfileComand {}),
+ CMDType::PrintfCmd => Box::new(PrintfComand {}),
+ CMDType::PushdCmd => Box::new(PushdCommand {}),
+ CMDType::DirsCmd => Box::new(DirsCommand {}),
+ CMDType::PopdCmd => Box::new(PopdComand {}),
+ CMDType::ReadCmd => Box::new(ReadComand {}),
+ CMDType::ReservedCmd => Box::new(ReservedComand {}),
+ CMDType::ReturnCmd => Box::new(ReturnComand {}),
+ CMDType::SetattrCmd => Box::new(SetattrComand {}),
+ CMDType::ExportCmd => Box::new(ExportComand {}),
+ CMDType::ReadonlyCmd => Box::new(ReadonlyComand {}),
+ CMDType::SetCmd => Box::new(SetComand {}),
+ CMDType::UnSetCmd => Box::new(UnSetComand {}),
+ CMDType::ShiftCmd => Box::new(ShiftComand {}),
+ CMDType::ShoptCmd => Box::new(ShoptComand {}),
+ CMDType::SourceCmd => Box::new(SourceComand {}),
+ CMDType::SuspendCmd => Box::new(SuspendComand {}),
+ CMDType::TestCmd => Box::new(TestComand {}),
+ CMDType::TimesCmd => Box::new(TimesComand {}),
+ CMDType::TrapCmd => Box::new(TrapComand {}),
+ CMDType::TypeCmd => Box::new(TypeComand {}),
+ CMDType::UlimitCmd => Box::new(UlimitComand {}),
+ CMDType::UmaskCmd => Box::new(UmaskComand {}),
+ CMDType::WaitCmd => Box::new(WaitComand {}),
+ CMDType::DisownCmd => Box::new(DisownCommand {}),
}
}
}
-unsafe fn get_cmd_type (command : *mut libc::c_char) -> CMDType{
+unsafe fn get_cmd_type(command: *mut libc::c_char) -> CMDType {
let mut types = CMDType::HelpCmd;
- if libc::strcmp(command, b"alias\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ if libc::strcmp(
+ command,
+ b"alias\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::AliasCmd;
}
- if libc::strcmp(command, b"unalias\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ if libc::strcmp(
+ command,
+ b"unalias\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::UnAliasCmd;
- }
- else if libc::strcmp(command, b"bind\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"bind\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::BindCmd;
- }
- else if libc::strcmp(command, b"break\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"break\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::BreakCmd;
- }
- else if libc::strcmp(command, b"continue\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"continue\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ContinueCmd;
- }
- else if libc::strcmp(command, b"builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"builtin\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::BuiltinCmd;
- }
- else if libc::strcmp(command, b"caller\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"caller\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CallerCmd;
- }
- else if libc::strcmp(command, b"cd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"cd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CdCmd;
- }
- else if libc::strcmp(command, b"pwd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"pwd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::PwdCmd;
- }
- else if libc::strcmp(command, b":\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0
- || libc::strcmp(command, b"true\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b":\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ || libc::strcmp(
+ command,
+ b"true\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ColonCmd;
- }
- else if libc::strcmp(command, b"false\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"false\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::FalseCmd;
- }
- else if libc::strcmp(command, b"command\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"command\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CommandCmd;
- }
- else if libc::strcmp(command, b"common\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"common\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CommonCmd;
- }
- else if libc::strcmp(command, b"complete\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"complete\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CompleteCmd;
- }
- else if libc::strcmp(command, b"compopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"compopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CompoptCmd;
- }
- else if libc::strcmp(command, b"compgen\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"compgen\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::CompgenCmd;
- }
- else if libc::strcmp(command,b"declare\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 || libc::strcmp(command,b"typeset\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"declare\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ || libc::strcmp(
+ command,
+ b"typeset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::DeclareCmd;
- }
- else if libc::strcmp(command,b"local\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"local\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::LocalCmd;
- }
- else if libc::strcmp(command,b"echo\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"echo\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::EchoCmd;
- }
-
- else if libc::strcmp(command,b"enable\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"enable\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::EnableCmd;
- }
- else if libc::strcmp(command,b"eval\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"eval\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::EvalCmd;
- }
-
- else if libc::strcmp(command,b"exec\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"exec\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ExecCmd;
- }
-
- else if libc::strcmp(command,b"exit\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"exit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ExitCmd;
- }
- else if libc::strcmp(command,b"logout\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"logout\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::LogoutCmd;
- }
- else if libc::strcmp(command,b"fc\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"fc\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::FcCmd;
- }
-
- else if libc::strcmp(command,b"fg\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"fg\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::FgCmd;
- }
- else if libc::strcmp(command,b"bg\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"bg\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::BgCmd;
- }
-
- else if libc::strcmp(command,b"getopts\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"getopts\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::GetoptsCmd;
- }
-
- else if libc::strcmp(command, b"hash\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"hash\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::HashCmd;
- }
- else if libc::strcmp(command,b"help\0" as *const u8 as *const libc::c_char as * mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"help\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::HelpCmd;
- }
- else if libc::strcmp(command,b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::HistoryCmd;
- }
- else if libc::strcmp(command,b"jobs\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"jobs\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::JobsCmd;
- }
- else if libc::strcmp(command, b"kill\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"kill\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::KillCmd;
- }
- else if libc::strcmp(command, b"mapfile\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 ||
- libc::strcmp(command, b"readarray\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
- types = CMDType::MapfileCmd;;
- }
- else if libc::strcmp(command,b"printf\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"mapfile\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ || libc::strcmp(
+ command,
+ b"readarray\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
+ types = CMDType::MapfileCmd;
+ } else if libc::strcmp(
+ command,
+ b"printf\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::PrintfCmd;
- }
- else if libc::strcmp(command,b"pushd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"pushd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::PushdCmd;
- }
- else if libc::strcmp(command,b"dirs\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"dirs\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::DirsCmd;
- }
- else if libc::strcmp(command,b"popd\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"popd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::PopdCmd;
- }
- else if libc::strcmp(command, b"read\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"read\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ReadCmd;
- }
-
- else if libc::strcmp(command, b"let\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"let\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::LetCmd;
- }
-
- else if libc::strcmp(command,b"return\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"return\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ReturnCmd;
- }
- else if libc::strcmp(command,b"set\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"set\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::SetCmd;
- }
- else if libc::strcmp(command,b"unset\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"unset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::UnSetCmd;
- }
- else if libc::strcmp(command,b"setattr\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"setattr\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::SetattrCmd;
- }
-
- else if libc::strcmp(command,b"readonly\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"readonly\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ReadonlyCmd;
- }
- else if libc::strcmp(command,b"export\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"export\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ExportCmd;
- }
- else if libc::strcmp(command,b"shift\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"shift\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ShiftCmd;
- }
-
- else if libc::strcmp(command,b"shopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"shopt\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::ShoptCmd;
- }
-
- else if libc::strcmp(command,b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0
- || libc::strcmp(command,b".\0" as *const u8 as *const libc::c_char as *mut libc::c_char)== 0 {
+ } else if libc::strcmp(
+ command,
+ b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ || libc::strcmp(
+ command,
+ b".\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::SourceCmd;
- }
-
- else if libc::strcmp(command, b"suspend\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"suspend\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::SuspendCmd;
- }
-
- else if libc::strcmp(command,b"test\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0
- || libc::strcmp(command,b"[\0" as *const u8 as *const libc::c_char as *mut libc::c_char)== 0 {
+ } else if libc::strcmp(
+ command,
+ b"test\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ || libc::strcmp(
+ command,
+ b"[\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::TestCmd;
- }
-
-
- else if libc::strcmp(command ,b"times\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"times\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::TimesCmd;
- }
- else if libc::strcmp(command ,b"trap\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"trap\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::TrapCmd;
- }
-
- else if libc::strcmp(command ,b"type\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"type\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::TypeCmd;
- }
-
- else if libc::strcmp(command ,b"ulimit\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0{
+ } else if libc::strcmp(
+ command,
+ b"ulimit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::UlimitCmd;
- }
-
- else if libc::strcmp(command ,b"umask\0" as *const u8 as *const libc::c_char as *mut libc::c_char ) == 0{
+ } else if libc::strcmp(
+ command,
+ b"umask\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::UmaskCmd;
- }
-
- else if libc::strcmp(command , b"wait\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"wait\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::WaitCmd;
- }
- else if libc::strcmp(command , b"disown\0" as *const u8 as *const libc::c_char as *mut libc::c_char) == 0 {
+ } else if libc::strcmp(
+ command,
+ b"disown\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ ) == 0
+ {
types = CMDType::DisownCmd;
}
-
- types
+
+ types
}
#[no_mangle]
-pub extern "C" fn r_exec_cmd(command : *mut libc::c_char, mut list :*mut WordList) -> i32 {
-
+pub extern "C" fn r_exec_cmd(command: *mut libc::c_char, list: *mut WordList) -> i32 {
// println!("enter r_exec_cmd");
// unsafe {
// println!("command is {:?}",CStr::from_ptr(command));
// }
- let commandType = unsafe {get_cmd_type(command)};
- let factory = SimpleFactory::new();
+ let commandType = unsafe { get_cmd_type(command) };
+ let factory = SimpleFactory::new();
let cmdCall = factory.make_product(commandType);
cmdCall.excute(list)
}
diff --git a/bash-5.1/builtins_rust/exit/src/lib.rs b/bash-5.1/builtins_rust/exit/src/lib.rs
index 1f0c5d96ab2c3ec4b967dcfa0798810af9e39e45..93f5a1e82b8b8b51f1a16c5969e6eff404af26d3 100644
--- a/bash-5.1/builtins_rust/exit/src/lib.rs
+++ b/bash-5.1/builtins_rust/exit/src/lib.rs
@@ -1,56 +1,57 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
-extern crate rjobs;
extern crate nix;
+extern crate rjobs;
use libc::c_char;
use std::ffi::CString;
-use rjobs::{PROCESS, COMMAND, r_jobs_builtin, JLIST_STANDARD};
+use rjobs::{r_jobs_builtin, COMMAND, JLIST_STANDARD, PROCESS};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,err_translate_fn};
+use rcommon::{
+ err_translate_fn, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE,
+};
use rhelp::r_builtin_help;
#[repr(C)]
pub struct JOB {
wd: *mut c_char,
pipe: *mut PROCESS,
- pgrp:i32,
- state:JOB_STATE,
- flags:i32,
- deferred:*mut COMMAND,
- j_cleanup:*mut fn(),
- cleanarg:* mut fn()
+ pgrp: i32,
+ state: JOB_STATE,
+ flags: i32,
+ deferred: *mut COMMAND,
+ j_cleanup: *mut fn(),
+ cleanarg: *mut fn(),
}
#[repr(C)]
pub struct jobstats {
/* limits */
- c_childmax:libc::c_long,
+ c_childmax: libc::c_long,
/* child process statistics */
- c_living:libc::c_int, /* running or stopped child processes */
- c_reaped:libc::c_int, /* exited child processes still in jobs list */
- c_injobs:libc::c_int, /* total number of child processes in jobs list */
+ c_living: libc::c_int, /* running or stopped child processes */
+ c_reaped: libc::c_int, /* exited child processes still in jobs list */
+ c_injobs: libc::c_int, /* total number of child processes in jobs list */
/* child process totals */
- c_totforked:libc::c_int, /* total number of children this shell has forked */
- c_totreaped:libc::c_int, /* total number of children this shell has reaped */
+ c_totforked: libc::c_int, /* total number of children this shell has forked */
+ c_totreaped: libc::c_int, /* total number of children this shell has reaped */
/* job counters and indices */
- j_jobslots:libc::c_int,/* total size of jobs array */
- j_lastj:libc::c_int, /* last (newest) job allocated */
- j_firstj:libc::c_int, /* first (oldest) job allocated */
- j_njobs:libc::c_int, /* number of non-NULL jobs in jobs array */
- j_ndead:libc::c_int, /* number of JDEAD jobs in jobs array */
+ j_jobslots: libc::c_int, /* total size of jobs array */
+ j_lastj: libc::c_int, /* last (newest) job allocated */
+ j_firstj: libc::c_int, /* first (oldest) job allocated */
+ j_njobs: libc::c_int, /* number of non-NULL jobs in jobs array */
+ j_ndead: libc::c_int, /* number of JDEAD jobs in jobs array */
/* */
- j_current:libc::c_int, /* current job */
- j_previous:libc::c_int, /* previous job */
+ j_current: libc::c_int, /* current job */
+ j_previous: libc::c_int, /* previous job */
/* */
- j_lastmade:* mut JOB, /* last job allocated by stop_pipeline */
- j_lastasync:* mut JOB /* last async job allocated by stop_pipeline */
+ j_lastmade: *mut JOB, /* last job allocated by stop_pipeline */
+ j_lastasync: *mut JOB, /* last async job allocated by stop_pipeline */
}
-
//枚举
#[repr(i8)]
#[derive(PartialEq)]
@@ -59,69 +60,73 @@ pub enum JOB_STATE {
JRUNNING = 1,
JSTOPPED = 2,
JDEAD = 4,
- JMIXED = 8
+ JMIXED = 8,
}
//宏
#[macro_export]
macro_rules! get_job_by_jid {
- ($ind:expr) => {
- (*((jobs as usize + ($ind*8) as usize ) as *mut*mut JOB) as *mut JOB)
- }
+ ($ind:expr) => {
+ (*((jobs as usize + ($ind * 8) as usize) as *mut *mut JOB) as *mut JOB)
+ };
}
#[macro_export]
macro_rules! STOPPED {
($j:expr) => {
(*get_job_by_jid!($j)).state == JOB_STATE::JSTOPPED
- }
+ };
}
#[macro_export]
-macro_rules! RUNNING{
+macro_rules! RUNNING {
($j:expr) => {
(*get_job_by_jid!($j)).state == JOB_STATE::JRUNNING
- }
+ };
}
#[macro_export]
-macro_rules! EXITPROG{
- () => { 3 }
+macro_rules! EXITPROG {
+ () => {
+ 3
+ };
}
#[macro_export]
macro_rules! SYS_BASH_LOGOOUT {
() => {
- CString::new(" \"/etc/bash.bash_logout\" ").unwrap().as_ptr()
- }
+ CString::new(" \"/etc/bash.bash_logout\" ")
+ .unwrap()
+ .as_ptr()
+ };
}
//C库
-extern "C"{
- static mut interactive:i32;
- static mut login_shell:i32;
+extern "C" {
+ static mut interactive: i32;
+ static mut login_shell: i32;
// static mut last_shell_builtin:*mut fn(v:*mut WordList)->i32;
- static mut last_shell_builtin:extern fn(v:*mut WordList)->i32;
+ static mut last_shell_builtin: extern "C" fn(v: *mut WordList) -> i32;
// static mut this_shell_builtin:*mut fn(v:*mut WordList)->i32;
- static mut this_shell_builtin:extern fn(v:*mut WordList)->i32;
- static js:jobstats ;
- static mut check_jobs_at_exit:i32;
- static mut jobs:*mut*mut JOB;
- static mut running_trap:i32;
- static mut trap_saved_exit_value:i32;
- static mut last_command_exit_value:i32;
- static subshell_environment:i32;
-
- fn builtin_error(err:*const c_char,...);
- fn list_all_jobs(form:i32);
- fn get_exitstat(list:*mut WordList) -> i32;
- fn jump_to_top_level(level:i32);
- fn maybe_execute_file(fname:*const c_char,force_noninteractive:i32)->i32;
+ static mut this_shell_builtin: extern "C" fn(v: *mut WordList) -> i32;
+ static js: jobstats;
+ static mut check_jobs_at_exit: i32;
+ static mut jobs: *mut *mut JOB;
+ static mut running_trap: i32;
+ static mut trap_saved_exit_value: i32;
+ static mut last_command_exit_value: i32;
+ static subshell_environment: i32;
+
+ fn builtin_error(err: *const c_char, ...);
+ fn list_all_jobs(form: i32);
+ fn get_exitstat(list: *mut WordList) -> i32;
+ fn jump_to_top_level(level: i32);
+ fn maybe_execute_file(fname: *const c_char, force_noninteractive: i32) -> i32;
}
-unsafe fn STREQ(a:*const c_char,b:*const c_char)->bool{
- return *a == *b && libc::strcmp(a,b) == 0;
+unsafe fn STREQ(a: *const c_char, b: *const c_char) -> bool {
+ return *a == *b && libc::strcmp(a, b) == 0;
}
// unsafe fn printToStderr(str:*mut c_char) -> std::io::Result<()>{
@@ -132,17 +137,19 @@ unsafe fn STREQ(a:*const c_char,b:*const c_char)->bool{
// }
//
-static mut sourced_logout:i32 = 0;
+static mut sourced_logout: i32 = 0;
#[no_mangle]
-pub extern "C" fn r_exit_builtin(list:*mut WordList) -> i32{
- unsafe{
+pub extern "C" fn r_exit_builtin(list: *mut WordList) -> i32 {
+ unsafe {
let c_str = CString::new("--help").unwrap();
let c_ptr = c_str.as_ptr();
- if list != std::ptr::null_mut() && (*list).word != std::ptr::null_mut() &&
- STREQ((*(*list).word).word, c_ptr){
- r_builtin_help();
- return EX_USAGE;
+ if list != std::ptr::null_mut()
+ && (*list).word != std::ptr::null_mut()
+ && STREQ((*(*list).word).word, c_ptr)
+ {
+ r_builtin_help();
+ return EX_USAGE;
}
if interactive != 0 {
@@ -151,15 +158,14 @@ pub extern "C" fn r_exit_builtin(list:*mut WordList) -> i32{
// printToStderr(str);
//eprintln!("logout");
let names = String::from("logout");
- err_translate_fn(&names,std::ptr::null_mut());
- println!();
- }else{
+ err_translate_fn(&names, std::ptr::null_mut());
+ println!();
+ } else {
// let str:*mut c_char = CString::new("exit\n").unwrap().into_raw();
// printToStderr(str);
eprintln!("exit");
// libc::fprintf(stderr,CString::new("exit\n").unwrap().as_ptr());
}
-
}
// libc::fflush(stderr);
return r_exit_or_logout(list);
@@ -167,52 +173,57 @@ pub extern "C" fn r_exit_builtin(list:*mut WordList) -> i32{
}
#[no_mangle]
-pub extern "C" fn r_logout_builtin(list:*mut WordList)->i32{
+pub extern "C" fn r_logout_builtin(list: *mut WordList) -> i32 {
unsafe {
let c_str = CString::new("--help").unwrap();
let c_ptr = c_str.as_ptr();
- if list != std::ptr::null_mut() && (*list).word != std::ptr::null_mut() &&
- STREQ((*(*list).word).word, c_ptr){
- r_builtin_help();
- return EX_USAGE;
+ if list != std::ptr::null_mut()
+ && (*list).word != std::ptr::null_mut()
+ && STREQ((*(*list).word).word, c_ptr)
+ {
+ r_builtin_help();
+ return EX_USAGE;
}
- if login_shell == 0{
+ if login_shell == 0 {
let names = String::from("logout");
- err_translate_fn(&names,std::ptr::null_mut());
- println!();
+ err_translate_fn(&names, std::ptr::null_mut());
+ println!();
let c_str = CString::new("not login shell: use `exit'").unwrap();
let c_ptr = c_str.as_ptr();
builtin_error(c_ptr);
return EXECUTION_FAILURE!();
- }else{
- return r_exit_or_logout(list)
+ } else {
+ return r_exit_or_logout(list);
}
}
}
-pub fn r_exit_or_logout(list:*mut WordList)->i32{
- let exit_value:i32;
- let exit_immediate_okay:i32;
- let mut stopmsg:i32;
+pub fn r_exit_or_logout(list: *mut WordList) -> i32 {
+ let exit_value: i32;
+ let exit_immediate_okay: i32;
+ let mut stopmsg: i32;
- unsafe{
- exit_immediate_okay = (interactive == 0 ||
- last_shell_builtin == r_exit_builtin ||
- last_shell_builtin == r_logout_builtin ||
- last_shell_builtin == r_jobs_builtin ) as i32;
+ unsafe {
+ exit_immediate_okay = (interactive == 0
+ || last_shell_builtin == r_exit_builtin
+ || last_shell_builtin == r_logout_builtin
+ || last_shell_builtin == r_jobs_builtin) as i32;
/* Check for stopped jobs if thw user wants to.*/
if exit_immediate_okay == 0 {
stopmsg = 0;
for i in 0..js.j_jobslots {
// println!("jobs: {}", i);
- if get_job_by_jid!(i) != std::ptr::null_mut() && STOPPED!(i){
+ if get_job_by_jid!(i) != std::ptr::null_mut() && STOPPED!(i) {
stopmsg = JOB_STATE::JSTOPPED as i32;
break;
- }
- else if (check_jobs_at_exit != 0) && (stopmsg ==0) && get_job_by_jid!(i) != std::ptr::null_mut() && RUNNING!(i) {
+ } else if (check_jobs_at_exit != 0)
+ && (stopmsg == 0)
+ && get_job_by_jid!(i) != std::ptr::null_mut()
+ && RUNNING!(i)
+ {
stopmsg = JOB_STATE::JRUNNING as i32;
break;
}
@@ -220,55 +231,52 @@ pub fn r_exit_or_logout(list:*mut WordList)->i32{
if stopmsg == JOB_STATE::JSTOPPED as i32 {
let names = String::from("stoppedjobs");
- err_translate_fn(&names,std::ptr::null_mut());
+ err_translate_fn(&names, std::ptr::null_mut());
eprintln!();
- }
- else if stopmsg == JOB_STATE::JRUNNING as i32{
+ } else if stopmsg == JOB_STATE::JRUNNING as i32 {
// libc::fprintf(stream,CString::new("There are runing jobs.\n").unwrap().as_ptr());
//eprintln!("There are runing jobs.");
let names = String::from("runjobs");
- err_translate_fn(&names,std::ptr::null_mut());
+ err_translate_fn(&names, std::ptr::null_mut());
eprintln!();
}
- if stopmsg == check_jobs_at_exit{
+ if stopmsg == check_jobs_at_exit {
list_all_jobs(JLIST_STANDARD!())
}
if stopmsg != 0 {
- last_shell_builtin = r_exit_builtin ;
- this_shell_builtin = last_shell_builtin ;
+ last_shell_builtin = r_exit_builtin;
+ this_shell_builtin = last_shell_builtin;
return EXECUTION_FAILURE!();
}
}
- if (running_trap ==1) && (list == std::ptr::null_mut())
- {
+ if (running_trap == 1) && (list == std::ptr::null_mut()) {
exit_value = trap_saved_exit_value;
- }else{
+ } else {
exit_value = get_exitstat(list);
}
r_bash_logout();
- last_command_exit_value = exit_value;
+ last_command_exit_value = exit_value;
jump_to_top_level(EXITPROG!());
- 0
+ 0
}
}
//#[no_mangle]
//pub extern "C" fn r_bash_logout(){
-pub fn r_bash_logout(){
- unsafe{
+pub fn r_bash_logout() {
+ unsafe {
if login_shell != 0 && sourced_logout == 0 && subshell_environment == 0 {
sourced_logout = sourced_logout + 1;
let c_str = CString::new("~/.bash_logout").unwrap();
let c_ptr = c_str.as_ptr();
- maybe_execute_file(c_ptr,1);
- maybe_execute_file(SYS_BASH_LOGOOUT!(),1);
+ maybe_execute_file(c_ptr, 1);
+ maybe_execute_file(SYS_BASH_LOGOOUT!(), 1);
}
}
-
}
diff --git a/bash-5.1/builtins_rust/fc/src/lib.rs b/bash-5.1/builtins_rust/fc/src/lib.rs
index 4b1daf2e03b12a39555224b1055bea9f262c8c3a..757b59ca3d05b573fa051eeb611f33fae350e989 100644
--- a/bash-5.1/builtins_rust/fc/src/lib.rs
+++ b/bash-5.1/builtins_rust/fc/src/lib.rs
@@ -1,14 +1,17 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
-use libc::{c_char, c_long, c_void, c_int};
-use nix::sys::termios::SpecialCharacterIndices;
-use std::{ffi::{CString,CStr}, i32, io::{Write, stdout}, ops::Add, string, u32};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,r_builtin_usage,r_savestring};
+use libc::{c_char, c_int, c_long, c_void};
+
+use rcommon::{
+ r_builtin_usage, r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS,
+ EX_USAGE,
+};
use rhelp::r_builtin_help;
+use std::{ffi::CString, i32, io::Write};
#[repr(i8)]
pub enum JOB_STATE {
@@ -16,264 +19,297 @@ pub enum JOB_STATE {
JRUNNING = 1,
JSTOPPED = 2,
JDEAD = 4,
- JMIXED = 8
+ JMIXED = 8,
}
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub struct PROCESS {
next: *mut PROCESS,
- pid:libc::c_int,
- status:libc::c_int,
- running:libc::c_int,
- command:*mut c_char
+ pid: libc::c_int,
+ status: libc::c_int,
+ running: libc::c_int,
+ command: *mut c_char,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub union REDIRECTEE {
- dest:libc::c_int,
- filename:* mut WordDesc
+ dest: libc::c_int,
+ filename: *mut WordDesc,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:REDIRECTEE,
- rflags:libc::c_int,
- flags:libc::c_int,
- instruction:r_instruction,
- redirectee:REDIRECTEE,
- here_doc_eof:*mut c_char
+ next: *mut REDIRECT,
+ redirector: REDIRECTEE,
+ rflags: libc::c_int,
+ flags: libc::c_int,
+ instruction: r_instruction,
+ redirectee: REDIRECTEE,
+ here_doc_eof: *mut c_char,
}
/* FOR command. */
#[repr(C)]
pub struct for_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:libc::c_int
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: libc::c_int,
}
#[repr(C)]
pub struct case_com {
- flags:libc::c_int,
- line:libc::c_int,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ flags: libc::c_int,
+ line: libc::c_int,
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct while_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore:libc::c_int,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector:libc::c_int
+ ignore: libc::c_int,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: libc::c_int,
}
#[repr(C)]
pub struct simple_com {
- flags:libc::c_int,
- line:libc::c_int,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: libc::c_int,
+ line: libc::c_int,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut c_char
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct group_com {
- ignore:libc::c_int,
- command:*mut COMMAND,
- source_file:*mut c_char
+ ignore: libc::c_int,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct select_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct arith_com {
- flags:libc::c_int,
- line:libc::c_int,
- exp:*mut WordList
+ flags: libc::c_int,
+ line: libc::c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct cond_com {
- flags:libc::c_int,
- line:libc::c_int,
- type_c:libc::c_int,
- exp:*mut WordList
+ flags: libc::c_int,
+ line: libc::c_int,
+ type_c: libc::c_int,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct arith_for_com {
- flags:libc::c_int,
- line:libc::c_int,
- init:*mut WordList,
- test:*mut WordList,
- step:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ init: *mut WordList,
+ test: *mut WordList,
+ step: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct subshell_com {
- flags:i32,
- line:i32,
- command:*mut COMMAND
+ flags: i32,
+ line: i32,
+ command: *mut COMMAND,
}
#[repr(C)]
pub struct coproc_com {
- flags:i32,
- name:*mut c_char,
- command:*mut COMMAND
+ flags: i32,
+ name: *mut c_char,
+ command: *mut COMMAND,
}
#[repr(C)]
pub union VALUE_COMMAND {
- For:*mut for_com,
- Case:*mut case_com,
- While:*mut while_com,
- If:*mut if_com,
- Connection:*mut connection,
- Simple:*mut simple_com,
- Function_def:*mut function_def,
- Group:*mut group_com,
- Select:*mut select_com,
- Arith:*mut arith_com,
- Cond:*mut cond_com,
- ArithFor:*mut arith_for_com,
- Subshell:*mut subshell_com,
- Coproc:*mut coproc_com
+ For: *mut for_com,
+ Case: *mut case_com,
+ While: *mut while_com,
+ If: *mut if_com,
+ Connection: *mut connection,
+ Simple: *mut simple_com,
+ Function_def: *mut function_def,
+ Group: *mut group_com,
+ Select: *mut select_com,
+ Arith: *mut arith_com,
+ Cond: *mut cond_com,
+ ArithFor: *mut arith_for_com,
+ Subshell: *mut subshell_com,
+ Coproc: *mut coproc_com,
}
#[repr(C)]
pub struct COMMAND {
- type_c:command_type,
- flags:i32,
- line:i32,
- redirects:*mut REDIRECT,
- value:VALUE_COMMAND
+ type_c: command_type,
+ flags: i32,
+ line: i32,
+ redirects: *mut REDIRECT,
+ value: VALUE_COMMAND,
}
#[repr(C)]
pub struct JOB {
wd: *mut c_char,
pipe: *mut PROCESS,
- pgrp:i32,
- state:JOB_STATE,
- flags:i32,
- deferred:*mut COMMAND,
- j_cleanup:*mut fn(),
- cleanarg:* mut fn()
+ pgrp: i32,
+ state: JOB_STATE,
+ flags: i32,
+ deferred: *mut COMMAND,
+ j_cleanup: *mut fn(),
+ cleanarg: *mut fn(),
}
#[repr(C)]
pub struct SHELL_VAR {
- name:*mut c_char,
- value:*mut c_char,
- exportstr:*mut c_char,
- dynamic_value:*mut fn(v:* mut SHELL_VAR)->*mut SHELL_VAR,
- assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut c_char,t:c_long,str2:* mut c_char)->*mut SHELL_VAR,
- attributes:i32,
- context:i32
+ name: *mut c_char,
+ value: *mut c_char,
+ exportstr: *mut c_char,
+ dynamic_value: *mut fn(v: *mut SHELL_VAR) -> *mut SHELL_VAR,
+ assign_func: *mut fn(
+ v: *mut SHELL_VAR,
+ str1: *mut c_char,
+ t: c_long,
+ str2: *mut c_char,
+ ) -> *mut SHELL_VAR,
+ attributes: i32,
+ context: i32,
}
#[repr(C)]
pub struct GENERIC_LIST {
- next: * mut GENERIC_LIST
+ next: *mut GENERIC_LIST,
}
#[repr(C)]
pub struct REPL {
- next: *mut REPL,
- pat:*mut c_char,
- rep:*mut c_char
+ next: *mut REPL,
+ pat: *mut c_char,
+ rep: *mut c_char,
}
#[repr(C)]
pub struct HIST_ENTRY {
- line:*mut c_char,
- timestamp:*mut c_char,
- data:*mut fn()
+ line: *mut c_char,
+ timestamp: *mut c_char,
+ data: *mut fn(),
}
-
#[macro_export]
macro_rules! ISHELP {
- ($s:expr) => {
- libc::strcmp($s as *const c_char,CString::new("--help").unwrap().as_ptr())
- }
+ ($s:expr) => {
+ libc::strcmp(
+ $s as *const c_char,
+ CString::new("--help").unwrap().as_ptr(),
+ )
+ };
}
#[macro_export]
macro_rules! errno {
- () => {
- *libc::__errno_location()
- }
+ () => {
+ *libc::__errno_location()
+ };
}
#[macro_export]
macro_rules! HN_LISTING {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
@@ -307,7 +343,7 @@ macro_rules! HIST_ERANGE {
#[macro_export]
macro_rules! HIST_NOTFOUND {
() => {
- std::i32::MIN +2
+ std::i32::MIN +4
}
}
@@ -450,7 +486,7 @@ unsafe fn printToStdoutflush() -> std::io::Result<()> {
unsafe fn QUIT ()
{
- if terminating_signal !=0 {
+ if terminating_signal == 0 {
termsig_handler (terminating_signal);
}
@@ -907,7 +943,7 @@ pub extern "C" fn r_fc_builtin (mut list:* mut WordList)->i32
#[no_mangle]
pub extern "C" fn r_fc_gethist (command:* mut c_char, hlist:* mut * mut HIST_ENTRY, mode:i32)->* mut c_char
{
- let mut i:i32;
+ let i:i32;
if hlist == std::ptr::null_mut() {
return std::ptr::null_mut();
@@ -928,13 +964,13 @@ pub extern "C" fn r_fc_gethnum (command:* mut c_char, hlist:* mut * mut HIST_ENT
{
let mut sign:i32;
let mut n:i32;
- let mut clen:i32;
- let mut rh:i32;
+ let clen:i32;
+ let rh:i32;
let mut i:i32=0;
let mut j:i32;
let mut last_hist:i32;
let mut real_last:i32;
- let mut listing:i32;
+ let listing:i32;
let mut s:* mut c_char;
diff --git a/bash-5.1/builtins_rust/fg_bg/src/lib.rs b/bash-5.1/builtins_rust/fg_bg/src/lib.rs
index f47ae236a7ecac2a2738f4a4d3d2e3fc02207c95..dea45de070bbf01ba131fda1255c52c7bb33acdd 100644
--- a/bash-5.1/builtins_rust/fg_bg/src/lib.rs
+++ b/bash-5.1/builtins_rust/fg_bg/src/lib.rs
@@ -1,13 +1,13 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
-use libc::{c_char, c_long};
-use std::{ffi::CString, ops::Add};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,r_builtin_usage};
+use libc::c_char;
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
+use std::{ffi::CString, ops::Add};
#[repr(i8)]
pub enum JOB_STATE {
@@ -15,470 +15,507 @@ pub enum JOB_STATE {
JRUNNING = 1,
JSTOPPED = 2,
JDEAD = 4,
- JMIXED = 8
+ JMIXED = 8,
}
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub struct PROCESS {
next: *mut PROCESS,
- pid:libc::c_int,
- status:libc::c_int,
- running:libc::c_int,
- command:*mut c_char
+ pid: libc::c_int,
+ status: libc::c_int,
+ running: libc::c_int,
+ command: *mut c_char,
}
-
-
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT, /* Next element, or NULL. */
- redirector:libc::c_int, /* Descriptor or varname to be redirected. */
- rflags:libc::c_int, /* Private flags for this redirection */
- flags:libc::c_int, /* Flag value for `open'. */
- instruction:r_instruction, /* What to do with the information. */
- redirectee:libc::c_int, /* File descriptor or filename */
- here_doc_eof:*mut c_char /* The word that appeared in < {
+ ($sig:expr, $nvar:expr, $ovar:expr) => {
$nvar.unwrap().clear();
$nvar.unwrap().add($sig);
$nvar.unwrap().clear();
- nix::sys::signal::sigprocmask(nix::sys::signal::SigmaskHow::SIG_BLOCK, $nvar, $ovar);
- }
+ nix::sys::signal::sigprocmask(nix::sys::signal::SigmaskHow::SIG_BLOCK, $nvar, $ovar);
+ };
}
#[macro_export]
macro_rules! UNBLOCK_SIGNAL {
- ($ovar:expr) => {
- nix::sys::signal::sigprocmask(nix::sys::signal::SigmaskHow::SIG_SETMASK, $ovar, None)
- }
+ ($ovar:expr) => {
+ nix::sys::signal::sigprocmask(nix::sys::signal::SigmaskHow::SIG_SETMASK, $ovar, None)
+ };
}
#[macro_export]
macro_rules! UNBLOCK_CHILD {
- ($ovar:expr) => {
- UNBLOCK_SIGNAL!($ovar);
- }
+ ($ovar:expr) => {
+ UNBLOCK_SIGNAL!($ovar);
+ };
}
#[macro_export]
macro_rules! BLOCK_CHILD {
- ($nvar:expr,$ovar:expr) => {
- BLOCK_SIGNAL!(nix::sys::signal::SIGCHLD, $nvar, $ovar);
- }
+ ($nvar:expr,$ovar:expr) => {
+ BLOCK_SIGNAL!(nix::sys::signal::SIGCHLD, $nvar, $ovar);
+ };
}
#[macro_export]
macro_rules! DUP_JOB {
- () => {-2}
+ () => {
+ -2
+ };
}
#[macro_export]
macro_rules! get_job_by_jid {
- ($ind:expr) => {
- (*(((jobs as usize) + ($ind*8) as usize ) as *mut*mut JOB) as *mut JOB)
- }
+ ($ind:expr) => {
+ (*(((jobs as usize) + ($ind * 8) as usize) as *mut *mut JOB) as *mut JOB)
+ };
}
#[macro_export]
macro_rules! J_JOBCONTROL {
- () => {0x04}
+ () => {
+ 0x04
+ };
}
#[macro_export]
macro_rules! IS_JOBCONTROL {
- ($j:expr) => {
- ((*get_job_by_jid!($j)).flags & J_JOBCONTROL!()) != 0
- }
+ ($j:expr) => {
+ ((*get_job_by_jid!($j)).flags & J_JOBCONTROL!()) != 0
+ };
}
#[macro_export]
macro_rules! INVALID_JOB {
- ($j:expr) => {
- $j <0 || $j >= js.j_jobslots || get_job_by_jid !($j) == std::ptr::null_mut()
- }
+ ($j:expr) => {
+ $j < 0 || $j >= js.j_jobslots || get_job_by_jid!($j) == std::ptr::null_mut()
+ };
}
#[macro_export]
macro_rules! ISHELP {
- ($s:expr) => {
- libc::strcmp($s as *const c_char,CString::new("--help").unwrap().as_ptr())
- }
+ ($s:expr) => {
+ libc::strcmp(
+ $s as *const c_char,
+ CString::new("--help").unwrap().as_ptr()
+ )
+ };
}
#[macro_export]
macro_rules! CHECK_HELPOPT {
- ($l:expr) => {
- if $l !=std::ptr::null_mut() && (*$l).word !=std::ptr::null_mut() && ISHELP!((*(*$l).word).word) == 0 {
- r_builtin_help ();
- return EX_USAGE;
- }
- }
+ ($l:expr) => {
+ if $l != std::ptr::null_mut()
+ && (*$l).word != std::ptr::null_mut()
+ && ISHELP!((*(*$l).word).word) == 0
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ };
}
-extern "C" {
- fn builtin_error(err:*const c_char,...);
- fn get_job_spec (list:*mut WordList)->i32;
- fn sh_badjob (str:*mut c_char);
- static jobs:*mut*mut JOB;
- static js:jobstats ;
-
- static mut loptend:*mut WordList;
- fn sh_nojobs (str:*mut c_char);
- fn no_options (list:*mut WordList)->i32;
- static mut job_control:i32;
- static mut last_asynchronous_pid:i32;
- fn start_job (job:i32, foreground:i32)->i32;
+extern "C" {
+ fn builtin_error(err: *const c_char, ...);
+ fn get_job_spec(list: *mut WordList) -> i32;
+ fn sh_badjob(str: *mut c_char);
+ static jobs: *mut *mut JOB;
+ static js: jobstats;
+
+ static mut loptend: *mut WordList;
+ fn sh_nojobs(str: *mut c_char);
+ fn no_options(list: *mut WordList) -> i32;
+ static mut job_control: i32;
+ static mut last_asynchronous_pid: i32;
+ fn start_job(job: i32, foreground: i32) -> i32;
}
/* How to bring a job into the foreground. */
#[no_mangle]
-pub extern "C" fn r_fg_builtin (list:*mut WordList)->i32 {
- let fg_bit:i32;
- unsafe {
- CHECK_HELPOPT! (list);
-
- if job_control == 0 {
- sh_nojobs (0 as *mut c_char);
- return EXECUTION_FAILURE!();
- }
+pub extern "C" fn r_fg_builtin(list: *mut WordList) -> i32 {
+ let fg_bit: i32;
+ unsafe {
+ CHECK_HELPOPT!(list);
+
+ if job_control == 0 {
+ sh_nojobs(0 as *mut c_char);
+ return EXECUTION_FAILURE!();
+ }
+
+ if no_options(list) != 0 {
+ return EX_USAGE;
+ }
- if no_options (list) !=0 {
- return EX_USAGE;
- }
-
- /* If the last arg on the line is '&', then start this job in the
- background. Else, fg the job. */
-
- if loptend == std::ptr::null_mut() {
- return r_fg_bg (loptend, 1);
- } else {
- let mut t:WordList=*loptend;
- while t.next !=std::ptr::null_mut() {
- t=*(t.next);
- }
- let cstr:&std::ffi::CStr=std::ffi::CStr::from_ptr((*(t.word)).word );
- let mut isfg:bool=char::from( cstr.to_bytes()[0] ) == '&';
- isfg =isfg && char::from( cstr.to_bytes()[1]) == '\0';
- isfg = isfg ==false;
- if isfg {
- fg_bit=1;
- } else {
- fg_bit=0;
- }
- return r_fg_bg (loptend, fg_bit);
+ /* If the last arg on the line is '&', then start this job in the
+ background. Else, fg the job. */
+
+ if loptend == std::ptr::null_mut() {
+ return r_fg_bg(loptend, 1);
+ } else {
+ let mut t: WordList = *loptend;
+ while t.next != std::ptr::null_mut() {
+ t = *(t.next);
+ }
+ let cstr: &std::ffi::CStr = std::ffi::CStr::from_ptr((*(t.word)).word);
+ let mut isfg: bool = char::from(cstr.to_bytes()[0]) == '&';
+ isfg = isfg && char::from(cstr.to_bytes()[1]) == '\0';
+ isfg = isfg == false;
+ if isfg {
+ fg_bit = 1;
+ } else {
+ fg_bit = 0;
+ }
+ return r_fg_bg(loptend, fg_bit);
+ }
}
- }
}
/* How to put a job into the background. */
#[no_mangle]
-pub extern "C" fn r_bg_builtin (list:*mut WordList)->i32 {
- let mut r:i32;
- unsafe {
- CHECK_HELPOPT !(list);
-
- if job_control == 0 {
- sh_nojobs (0 as *mut c_char);
- return EXECUTION_FAILURE!();
- }
-
- if no_options (list) !=0 {
- return EX_USAGE;
- }
-
- /* This relies on the fact that fg_bg() takes a WordList *, but only acts
- on the first member (if any) of that list. */
- r = EXECUTION_SUCCESS!();
-
- if r_fg_bg(loptend,0) == EXECUTION_FAILURE!() {
- r = EXECUTION_FAILURE!();
- }
-
- if loptend !=std::ptr::null_mut() {
- let mut t:WordList=*loptend;
- while t.next !=std::ptr::null_mut() {
- if r_fg_bg (&mut t, 0) == EXECUTION_FAILURE!() {
- r = EXECUTION_FAILURE!();
+pub extern "C" fn r_bg_builtin(list: *mut WordList) -> i32 {
+ let mut r: i32;
+ unsafe {
+ CHECK_HELPOPT!(list);
+
+ if job_control == 0 {
+ sh_nojobs(0 as *mut c_char);
+ return EXECUTION_FAILURE!();
+ }
+
+ if no_options(list) != 0 {
+ return EX_USAGE;
+ }
+
+ /* This relies on the fact that fg_bg() takes a WordList *, but only acts
+ on the first member (if any) of that list. */
+ r = EXECUTION_SUCCESS!();
+
+ if r_fg_bg(loptend, 0) == EXECUTION_FAILURE!() {
+ r = EXECUTION_FAILURE!();
+ }
+
+ if loptend != std::ptr::null_mut() {
+ let mut t: WordList = *loptend;
+ while t.next != std::ptr::null_mut() {
+ if r_fg_bg(&mut t, 0) == EXECUTION_FAILURE!() {
+ r = EXECUTION_FAILURE!();
+ }
+ t = *(t.next);
+ }
+ return r;
+ } else {
+ return r;
}
- t = *(t.next);
- }
- return r;
- } else {
- return r;
- }
- }
+ }
}
/* How to put a job into the foreground/background. */
#[no_mangle]
-pub extern "C" fn r_fg_bg (list:*mut WordList, foreground:i32)->i32{
-
- let mut set:nix::sys::signal::SigSet=nix::sys::signal::SigSet::empty();
- let mut oset:nix::sys::signal::SigSet =nix::sys::signal::SigSet::empty();
- let job:i32;
- let status:i32;
- let mut old_async_pid:i32=0;
- let j:*mut JOB;
-
- unsafe {
- BLOCK_CHILD !(Some(&mut set), Some(&mut oset));
- job = get_job_spec (list);
-
- if INVALID_JOB !(job) {
- if job != DUP_JOB!() {
- if list != std::ptr::null_mut() {
- sh_badjob ( (*(*list).word).word );
- } else {
- let mut c_str_current = CString::new("current").unwrap(); // from a &str, creates a new allocation
- sh_badjob (c_str_current.as_ptr() as * mut c_char);
- }
- }
+pub extern "C" fn r_fg_bg(list: *mut WordList, foreground: i32) -> i32 {
+ let mut set: nix::sys::signal::SigSet = nix::sys::signal::SigSet::empty();
+ let mut oset: nix::sys::signal::SigSet = nix::sys::signal::SigSet::empty();
+ let job: i32;
+ let status: i32;
+ let mut old_async_pid: i32 = 0;
+ let j: *mut JOB;
+
+ unsafe {
+ BLOCK_CHILD!(Some(&mut set), Some(&mut oset));
+ job = get_job_spec(list);
+
+ if INVALID_JOB!(job) {
+ if job != DUP_JOB!() {
+ if list != std::ptr::null_mut() {
+ sh_badjob((*(*list).word).word);
+ } else {
+ let c_str_current = CString::new("current").unwrap(); // from a &str, creates a new allocation
+ sh_badjob(c_str_current.as_ptr() as *mut c_char);
+ }
+ }
+
+ UNBLOCK_CHILD!(Some(&oset));
+ return EXECUTION_FAILURE!();
+ }
+
+ j = get_job_by_jid!(job);
+ /* Or if j->pgrp == shell_pgrp. */
+ if !IS_JOBCONTROL!(job) {
+ let jobNum: i32 = job + 1;
+ builtin_error(
+ String::from("job ")
+ .add(&jobNum.to_string())
+ .add(&String::from("started without job control").to_string())
+ .as_ptr() as *const c_char,
+ );
+ UNBLOCK_CHILD!(Some(&oset));
+ return EXECUTION_FAILURE!();
+ }
+
+ if foreground == 0 {
+ old_async_pid = i32::from(last_asynchronous_pid);
+ last_asynchronous_pid = i32::from((*j).pgrp); /* As per Posix.2 5.4.2 */
+ }
- UNBLOCK_CHILD !(Some(&oset));
- return EXECUTION_FAILURE!();
- }
-
- j = get_job_by_jid !(job);
- /* Or if j->pgrp == shell_pgrp. */
- if ! IS_JOBCONTROL !(job) {
- let jobNum:i32=job + 1;
- builtin_error ( String::from("job ").add(&jobNum.to_string()).add(&String::from("started without job control").to_string()).as_ptr() as * const c_char);
- UNBLOCK_CHILD !(Some(&oset));
- return EXECUTION_FAILURE!();
- }
-
- if foreground == 0 {
- old_async_pid = i32::from(last_asynchronous_pid);
- last_asynchronous_pid = i32::from((*j).pgrp); /* As per Posix.2 5.4.2 */
- }
-
- status = start_job (job, foreground);
-
- if status >= 0 {
- /* win: */
- UNBLOCK_CHILD !(Some(&oset));
- if foreground !=0 {
- return status;
- } else {
- return EXECUTION_SUCCESS!();
- }
- } else {
- if foreground == 0 {
- last_asynchronous_pid = i32::from(old_async_pid);
- }
-
- UNBLOCK_CHILD !(Some(&oset));
- return EXECUTION_FAILURE!();
+ status = start_job(job, foreground);
+
+ if status >= 0 {
+ /* win: */
+ UNBLOCK_CHILD!(Some(&oset));
+ if foreground != 0 {
+ return status;
+ } else {
+ return EXECUTION_SUCCESS!();
+ }
+ } else {
+ if foreground == 0 {
+ last_asynchronous_pid = i32::from(old_async_pid);
+ }
+
+ UNBLOCK_CHILD!(Some(&oset));
+ return EXECUTION_FAILURE!();
+ }
}
- }
}
/*
diff --git a/bash-5.1/builtins_rust/getopts/src/lib.rs b/bash-5.1/builtins_rust/getopts/src/lib.rs
index 91eda74803adb60cd5a6b2eda9cb473c54efa33f..4736107685b3981b5ea6f502570981722dabe96d 100644
--- a/bash-5.1/builtins_rust/getopts/src/lib.rs
+++ b/bash-5.1/builtins_rust/getopts/src/lib.rs
@@ -3,7 +3,7 @@
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate nix;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,GETOPT_HELP, r_builtin_usage};
+use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE,GETOPT_HELP};
use libc::{c_char, c_long, c_void};
use std::{ffi::CString};
use rhelp::r_builtin_help;
diff --git a/bash-5.1/builtins_rust/hash/Cargo.tom b/bash-5.1/builtins_rust/hash/Cargo.tom
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/bash-5.1/builtins_rust/hash/src/lib.rs b/bash-5.1/builtins_rust/hash/src/lib.rs
index 769cde8c78dd2c8ff3d7eb1c98cfbd73f9175fd2..462d73a9b0447de5231314da0a44ff313e1f642d 100644
--- a/bash-5.1/builtins_rust/hash/src/lib.rs
+++ b/bash-5.1/builtins_rust/hash/src/lib.rs
@@ -1,39 +1,39 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate rread;
-use libc::{c_char,c_int, strchr,free,c_void,strerror,EISDIR};
-use std::ffi::{CStr,CString};
-use std::io::{stdout, Write};
-use rread::{SHELL_VAR};
-use rcommon::{r_find_shell_builtin,r_builtin_usage};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
+use libc::{c_char, c_int, c_void, free, strchr, strerror, EISDIR};
+use rcommon::r_builtin_usage;
+use rcommon::{WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
+use rread::SHELL_VAR;
+use std::ffi::{CStr, CString};
use std::fs;
+use std::io::{stdout, Write};
use std::os::linux::fs::MetadataExt;
-type PTR_T=c_void;
-#[repr (C)]
-pub struct bucket_contents{
- pub next:*mut bucket_contents,
- pub key:*mut c_char,
- pub data:*mut PTR_T, //void * or char *
- pub khash:u32,
- pub times_found:i32,
+type PTR_T = c_void;
+#[repr(C)]
+pub struct bucket_contents {
+ pub next: *mut bucket_contents,
+ pub key: *mut c_char,
+ pub data: *mut PTR_T, //void * or char *
+ pub khash: u32,
+ pub times_found: i32,
}
-type BUCKET_CONTENTS=bucket_contents;
-#[repr (C)]
-pub struct hash_table{
- pub bucket_array:*mut *mut BUCKET_CONTENTS,
- pub nbucjets:i32,
- pub nentries:i32,
+type BUCKET_CONTENTS = bucket_contents;
+#[repr(C)]
+pub struct hash_table {
+ pub bucket_array: *mut *mut BUCKET_CONTENTS,
+ pub nbucjets: i32,
+ pub nentries: i32,
}
type HASH_TABLE = hash_table;
-#[repr (C)]
-pub struct _pathdata{
- pub path:*mut c_char,
- pub flags:i32,
+#[repr(C)]
+pub struct _pathdata {
+ pub path: *mut c_char,
+ pub flags: i32,
}
type PATH_DATA = _pathdata;
//enum
@@ -53,20 +53,18 @@ pub unsafe fn hash_entries(ht: *mut HASH_TABLE) -> i32 {
#[macro_export]
macro_rules! HASH_ENTRIES {
($ht:expr) => {
- if ($ht) != std::ptr::null_mut(){
+ if ($ht) != std::ptr::null_mut() {
return (*$ht).nentries;
- }
- else{
+ } else {
return 0;
}
};
}
-fn HASH_ENTRIES(ht:*mut HASH_TABLE)->i32{
- unsafe{
- if ht != std::ptr::null_mut(){
+fn HASH_ENTRIES(ht: *mut HASH_TABLE) -> i32 {
+ unsafe {
+ if ht != std::ptr::null_mut() {
return (*ht).nentries;
- }
- else{
+ } else {
return 0;
}
}
@@ -80,7 +78,7 @@ macro_rules! pathdata {
#[macro_export]
macro_rules! FREE {
($s:expr) => {
- if $s != std::ptr::null_mut(){
+ if $s != std::ptr::null_mut() {
free($s as *mut c_void);
}
};
@@ -94,56 +92,56 @@ pub struct alias {
}
pub type AliasT = alias;
// type i32 hash_efunc PARAMS(*mut BUCKET_CONTENTS);
-type hash_wfunc = extern fn(*mut BUCKET_CONTENTS)->i32;
-type sh_builtin_func_t = extern fn (*mut WordList)->i32;
+type hash_wfunc = extern "C" fn(*mut BUCKET_CONTENTS) -> i32;
+type sh_builtin_func_t = extern "C" fn(*mut WordList) -> i32;
//extern c
-extern "C"{
- static loptend:*mut WordList;
- static hashing_enabled:i32;
- static list_optarg:*mut c_char;
- static this_command_name:*mut c_char;
- static posixly_correct:i32;
- static restricted:i32;
- static shell_compatibility_level:i32;
- static hashed_filenames:*mut HASH_TABLE;
- static dot_found_in_search:i32;
- fn builtin_error(format:*const c_char,...);
+extern "C" {
+ static loptend: *mut WordList;
+ static hashing_enabled: i32;
+ static list_optarg: *mut c_char;
+ static this_command_name: *mut c_char;
+ static posixly_correct: i32;
+ static restricted: i32;
+ static shell_compatibility_level: i32;
+ static hashed_filenames: *mut HASH_TABLE;
+ static dot_found_in_search: i32;
+ fn builtin_error(format: *const c_char, ...);
fn reset_internal_getopt();
- fn internal_getopt(list:*mut WordList,opts:*mut c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
fn all_aliases() -> *mut *mut AliasT;
- fn sh_needarg(s:*mut c_char);
+ fn sh_needarg(s: *mut c_char);
fn phash_flush();
- fn sh_restricted(s:*mut c_char);
- fn absolute_program(string:*const c_char)->i32;
- fn find_user_command(name:*const c_char)->*mut c_char;
- fn executable_file(file:*const c_char)->i32;
- fn sh_notfound(s:*mut c_char);
- fn is_directory(file:*const c_char)->i32;
- fn phash_insert(filename:*mut c_char,full_path:*mut c_char,check_dot:i32,found:i32);
- fn phash_remove(filename:*const c_char)->i32;
- fn find_function(name:*const c_char)->*mut SHELL_VAR;
- fn find_shell_builtin(name:*mut c_char)->*mut sh_builtin_func_t;
- fn hash_walk(table:*mut HASH_TABLE,func:*mut hash_wfunc);
- fn phash_search(filename:*const c_char)->*mut c_char;
- fn printable_filename(f:*mut c_char,flage:i32)->*mut c_char;
+ fn sh_restricted(s: *mut c_char);
+ fn absolute_program(string: *const c_char) -> i32;
+ fn find_user_command(name: *const c_char) -> *mut c_char;
+ fn executable_file(file: *const c_char) -> i32;
+ fn sh_notfound(s: *mut c_char);
+ fn is_directory(file: *const c_char) -> i32;
+ fn phash_insert(filename: *mut c_char, full_path: *mut c_char, check_dot: i32, found: i32);
+ fn phash_remove(filename: *const c_char) -> i32;
+ fn find_function(name: *const c_char) -> *mut SHELL_VAR;
+ fn find_shell_builtin(name: *mut c_char) -> *mut sh_builtin_func_t;
+ fn hash_walk(table: *mut HASH_TABLE, func: *mut hash_wfunc);
+ fn phash_search(filename: *const c_char) -> *mut c_char;
+ fn printable_filename(f: *mut c_char, flage: i32) -> *mut c_char;
}
static mut common_inode: c_int = 0;
//rust
/* Print statistics on the current state of hashed commands. If LIST is
- not empty, then rehash (or hash in the first place) the specified
- commands. */
+not empty, then rehash (or hash in the first place) the specified
+commands. */
#[no_mangle]
-pub extern "C" fn r_hash_builtin(mut list:*mut WordList)->i32{
- let mut expunge_hash_table:i32;
- let mut list_targets:i32;
- let mut list_portably:i32;
- let mut delete:i32;
- let mut opt:i32;
- let mut w:*mut c_char;
- let mut pathname:*mut c_char;
- unsafe{
- if hashing_enabled == 0{
+pub extern "C" fn r_hash_builtin(mut list: *mut WordList) -> i32 {
+ let mut expunge_hash_table: i32;
+ let mut list_targets: i32;
+ let mut list_portably: i32;
+ let mut delete: i32;
+ let mut opt: i32;
+ let mut w: *mut c_char;
+ let mut pathname: *mut c_char;
+ unsafe {
+ if hashing_enabled == 0 {
let c_str = CString::new("hashing disabled").unwrap();
let c_str_ptr = c_str.as_ptr();
builtin_error(c_str_ptr);
@@ -156,73 +154,75 @@ pub extern "C" fn r_hash_builtin(mut list:*mut WordList)->i32{
pathname = std::ptr::null_mut();
reset_internal_getopt();
let opts = CString::new("dlp:rt").unwrap();
- opt = internal_getopt(list,opts.as_ptr() as *mut c_char);
- while opt != -1{
+ opt = internal_getopt(list, opts.as_ptr() as *mut c_char);
+ while opt != -1 {
let optu8 = opt as u8;
let opt_char = char::from(optu8);
- match opt_char{
+ match opt_char {
'd' => delete = 1,
'l' => list_portably = 1,
'p' => pathname = list_optarg,
'r' => expunge_hash_table = 1,
't' => list_targets = 1,
- _ => {
+ _ => {
if opt == -99 {
r_builtin_help();
return EX_USAGE;
}
- r_builtin_usage();
- return EX_USAGE;
- }
+ r_builtin_usage();
+ return EX_USAGE;
+ }
}
- opt = internal_getopt(list,opts.as_ptr() as *mut c_char);
+ opt = internal_getopt(list, opts.as_ptr() as *mut c_char);
}
list = loptend;
/* hash -t requires at least one argument. */
if list == std::ptr::null_mut() && (delete != 0 || list_targets != 0) {
- let temp:CString;
- let temp_ptr:*mut c_char;
- if delete != 0{
+ let temp: CString;
+ let temp_ptr: *mut c_char;
+ if delete != 0 {
temp = CString::new("-d").unwrap();
temp_ptr = temp.as_ptr() as *mut c_char;
sh_needarg(temp_ptr);
- }
- else{
+ } else {
temp = CString::new("-t").unwrap();
temp_ptr = temp.as_ptr() as *mut c_char;
sh_needarg(temp_ptr);
}
return EXECUTION_FAILURE!();
}
-
+
/* We want hash -r to be silent, but hash -- to print hashing info, so
- we test expunge_hash_table. */
- if list==std::ptr::null_mut() && expunge_hash_table == 0{
+ we test expunge_hash_table. */
+ if list == std::ptr::null_mut() && expunge_hash_table == 0 {
opt = r_print_hashed_commands(list_portably);
- if opt==0 && posixly_correct==0 && (list_portably==0 || shell_compatibility_level<=50){
+ if opt == 0
+ && posixly_correct == 0
+ && (list_portably == 0 || shell_compatibility_level <= 50)
+ {
let s_cstr = CStr::from_ptr(this_command_name);
let s_str = s_cstr.to_str().unwrap();
let s_string = s_str.to_owned();
- println!("{}:hash table empty",s_string);
+ println!("{}:hash table empty", s_string);
}
return EXECUTION_SUCCESS!();
}
- if expunge_hash_table != 0{
+ if expunge_hash_table != 0 {
phash_flush();
}
/* If someone runs `hash -r -t xyz' he will be disappointed. */
- if list_targets != 0{
- return r_list_hashed_filename_targets(list,list_portably);
+ if list_targets != 0 {
+ return r_list_hashed_filename_targets(list, list_portably);
}
- if restricted != 0 && pathname != std::ptr::null_mut(){
- if strchr(pathname,'/' as c_int) != std::ptr::null_mut(){
+ if restricted != 0 && pathname != std::ptr::null_mut() {
+ if strchr(pathname, '/' as c_int) != std::ptr::null_mut() {
sh_restricted(pathname);
return EXECUTION_FAILURE!();
}
/* If we are changing the hash table in a restricted shell, make sure the
- target pathname can be found using a $PATH search. */
+ target pathname can be found using a $PATH search. */
w = find_user_command(pathname);
- if w==std::ptr::null_mut() || *w==0 || executable_file(w)==0{
+ if w == std::ptr::null_mut() || *w == 0 || executable_file(w) == 0 {
sh_notfound(pathname);
free(w as *mut c_void);
return EXECUTION_FAILURE!();
@@ -230,55 +230,49 @@ pub extern "C" fn r_hash_builtin(mut list:*mut WordList)->i32{
free(w as *mut c_void);
}
opt = EXECUTION_SUCCESS!();
- while list != std::ptr::null_mut(){
+ while list != std::ptr::null_mut() {
/* Add, remove or rehash the specified commands. */
w = (*(*list).word).word;
- if absolute_program(w as *const c_char) != 0{
+ if absolute_program(w as *const c_char) != 0 {
continue;
- }
- else if pathname != std::ptr::null_mut(){
- if is_directory(pathname) != 0{
+ } else if pathname != std::ptr::null_mut() {
+ if is_directory(pathname) != 0 {
let c_err = CString::new("%s:%s").unwrap();
let c_err_ptr = c_err.as_ptr();
- builtin_error(c_err_ptr,pathname,strerror(EISDIR));
+ builtin_error(c_err_ptr, pathname, strerror(EISDIR));
opt = EXECUTION_SUCCESS!();
+ } else {
+ if legal_hash_rust(w, pathname) == 0 {
+ phash_insert(w, pathname, 0, 0);
+ }
}
- else{
- if legal_hash_rust(w,pathname) == 0{
- phash_insert(w,pathname,0,0);
- }
-
- }
- }
- else if delete != 0{
- if phash_remove(w) != 0{
+ } else if delete != 0 {
+ if phash_remove(w) != 0 {
sh_notfound(w);
opt = EXECUTION_FAILURE!();
}
- }
- else if r_add_hashed_command(w,0) != 0{
+ } else if r_add_hashed_command(w, 0) != 0 {
opt = EXECUTION_FAILURE!();
}
list = (*list).next;
}
stdout().flush();
return opt;
- }//unsafe
+ } //unsafe
}
-extern "C" fn r_add_hashed_command(w:*mut c_char,quiet:i32)->i32{
- let mut rv:i32;
- let full_path:*mut c_char;
- rv = 0;
- unsafe{
- if find_function(w).is_null() && find_shell_builtin(w).is_null(){
- // if find_function(w).is_null() && r_find_shell_builtin(w).is_null(){
+extern "C" fn r_add_hashed_command(w: *mut c_char, quiet: i32) -> i32 {
+ let mut rv: i32;
+ let full_path: *mut c_char;
+ rv = 1;
+ unsafe {
+ if find_function(w).is_null() && find_shell_builtin(w).is_null() {
+ // if find_function(w).is_null() && r_find_shell_builtin(w).is_null(){
phash_remove(w);
full_path = find_user_command(w);
- if full_path != std::ptr::null_mut() && executable_file(full_path) != 0{
- phash_insert(w,full_path,dot_found_in_search,0)
- }
- else{
- if quiet == 0{
+ if full_path != std::ptr::null_mut() && executable_file(full_path) != 0 {
+ phash_insert(w, full_path, dot_found_in_search, 0)
+ } else {
+ if quiet == 0 {
sh_notfound(w);
}
rv += 1;
@@ -286,53 +280,51 @@ extern "C" fn r_add_hashed_command(w:*mut c_char,quiet:i32)->i32{
FREE!(full_path);
}
return rv;
- }//unsafe
+ }
}
-extern "C" fn r_print_hash_info(item:*mut BUCKET_CONTENTS)->i32{
-
- unsafe{
- let path_string = CStr::from_ptr((*pathdata!(item)).path).to_str().unwrap();//.to_owned()
- println!("{:04}\t{}",(*item).times_found,path_string);
+extern "C" fn r_print_hash_info(item: *mut BUCKET_CONTENTS) -> i32 {
+ unsafe {
+ let path_string = CStr::from_ptr((*pathdata!(item)).path).to_str().unwrap(); //.to_owned()
+ println!("{:04}\t{}", (*item).times_found, path_string);
// println!("{:04}\t{}",(*item).times_found,*(*pathdata!(item)).path);
- }//unsafe
+ }
0
}
#[no_mangle]
-extern "C" fn r_print_portable_hash_info(item:*mut BUCKET_CONTENTS)->i32{
- let fp:*mut c_char;
- let f:*mut c_char;
- unsafe{
- fp = printable_filename((*pathdata!(item)).path,1);
- f = printable_filename((*item).key,1);
- let fp_string = CStr::from_ptr(fp).to_str().unwrap();//.to_owned()
- let f_string = CStr::from_ptr(f).to_str().unwrap();//.to_owned()
- println!("builtin hash -p {} {}",fp_string,f_string);
- if fp != (*pathdata!(item)).path{
+extern "C" fn r_print_portable_hash_info(item: *mut BUCKET_CONTENTS) -> i32 {
+ let fp: *mut c_char;
+ let f: *mut c_char;
+ unsafe {
+ fp = printable_filename((*pathdata!(item)).path, 1);
+ f = printable_filename((*item).key, 1);
+ let fp_string = CStr::from_ptr(fp).to_str().unwrap(); //.to_owned()
+ let f_string = CStr::from_ptr(f).to_str().unwrap(); //.to_owned()
+ println!("builtin hash -p {} {}", fp_string, f_string);
+ if fp != (*pathdata!(item)).path {
free(fp as *mut c_void);
}
- if f != (*item).key{
+ if f != (*item).key {
free(f as *mut c_void);
}
return 0;
- }//unsafe
+ }
}
#[no_mangle]
-extern "C" fn r_print_hashed_commands(fmt:i32)->i32{
- unsafe{
+extern "C" fn r_print_hashed_commands(fmt: i32) -> i32 {
+ unsafe {
if hashed_filenames.is_null() || hash_entries(hashed_filenames) == 0 {
return 0;
}
- if fmt == 0{
+ if fmt == 0 {
println!("hits\tcommand");
}
- let fmt_t:hash_wfunc;
- if fmt != 0{
+ let fmt_t: hash_wfunc;
+ if fmt != 0 {
fmt_t = r_print_portable_hash_info;
- }
- else{
+ } else {
fmt_t = r_print_hash_info;
}
- hash_walk(hashed_filenames,fmt_t as *mut hash_wfunc);
+ hash_walk(hashed_filenames, fmt_t as *mut hash_wfunc);
return 1;
}
}
@@ -388,8 +380,8 @@ unsafe fn legal_hash_rust(name :*mut libc::c_char,value :*mut libc::c_char ) ->
let alias_list: *mut *mut AliasT = all_aliases();
let mut t: *mut AliasT;
let mut offset;
- let mut name_w:*mut libc::c_char;
- let mut target:*mut c_char;
+ let name_w:*mut libc::c_char;
+ let target:*mut c_char;
offset = 0;
if !alias_list.is_null() {
t = *alias_list.offset(offset as isize);
@@ -432,9 +424,9 @@ unsafe fn file_inode(pathname : &str,pathname2 : &str) -> std::io::Result<()> {
let meta = fs::metadata( pathname )?;
let meta2 = fs::metadata( pathname2 )?;
common_inode = 0;
- if (meta.st_ino() != meta2.st_ino()) {
+ if meta.st_ino() != meta2.st_ino() {
println!("The name and value point to different executable files");
common_inode = 1;
}
Ok(())
-}
\ No newline at end of file
+}
diff --git a/bash-5.1/builtins_rust/help/src/lib.rs b/bash-5.1/builtins_rust/help/src/lib.rs
index 847fa1803682473753c5299b7a745c4ffd06e1c4..d556de0a3076120b36512aa3c87350cde84fd0ee 100644
--- a/bash-5.1/builtins_rust/help/src/lib.rs
+++ b/bash-5.1/builtins_rust/help/src/lib.rs
@@ -1,538 +1,587 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
extern crate std;
-use libc::{c_char, c_void ,putchar, free};
-use std::{ffi::{CString,CStr}, i32, io::{Read, stdout, Write}, mem, string, u32};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS,
- EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,
- r_builtin_usage,get_local_str};
-
-use fluent_bundle::{FluentBundle, FluentResource, FluentValue, FluentArgs};
+use libc::{c_char, c_void};
+use rcommon::{get_local_str, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
+use std::{
+ ffi::{CStr, CString},
+ i32,
+ io::Write,
+};
+
+use fluent_bundle::FluentArgs;
use fluent_resmgr::resource_manager::ResourceManager;
pub enum Option {
None,
Some(T),
}
-#[repr (C)]
-#[derive(Copy,Clone)]
+#[repr(C)]
+#[derive(Copy, Clone)]
pub struct builtin {
- name : *mut libc::c_char,
- function :*mut sh_builtin_func_t,
- flags : bool,
- long_doc :*mut *mut c_char,
- short_doc :*mut libc::c_char,
- handle :*mut libc::c_char
+ name: *mut libc::c_char,
+ function: *mut sh_builtin_func_t,
+ flags: bool,
+ long_doc: *mut *mut c_char,
+ short_doc: *mut libc::c_char,
+ handle: *mut libc::c_char,
}
type sh_builtin_func_t = fn(WordList) -> i32;
#[repr(C)]
struct FieldStruct {
- name : *mut c_char,
+ name: *mut c_char,
}
#[macro_export]
macro_rules! FNMATCH_EXTFLAG {
- () => {0}
+ () => {
+ 0
+ };
}
#[macro_export]
macro_rules! EX_USAGE {
- () => {258}
+ () => {
+ 258
+ };
}
#[macro_export]
-macro_rules! MB_CUR_MAX {
- () => {6}
- }
+macro_rules! MB_CUR_MAX {
+ () => {
+ 6
+ };
+}
#[macro_export]
-macro_rules! BASE_INDENT{
- () => {4}
+macro_rules! BASE_INDENT {
+ () => {
+ 4
+ };
}
#[macro_export]
-macro_rules! BUILTIN_ENABLED{
- () => {1}
+macro_rules! BUILTIN_ENABLED {
+ () => {
+ 1
+ };
}
#[macro_export]
-macro_rules! FNM_NOMATCH{
- () => {1}
+macro_rules! FNM_NOMATCH {
+ () => {
+ 1
+ };
}
#[macro_export]
-macro_rules! BUILTIN_SIZEOF{
- () => {48}
+macro_rules! BUILTIN_SIZEOF {
+ () => {
+ 48
+ };
}
#[macro_export]
-macro_rules! EXIT_FAILURE{
- () => {1}
+macro_rules! EXIT_FAILURE {
+ () => {
+ 1
+ };
}
-extern "C"{
+extern "C" {
fn reset_internal_getopt();
- fn internal_getopt (list:*mut WordList , opts:*mut c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut c_char) -> i32;
//fn builtin_error(err:*const c_char,...);
fn builtin_usage();
- fn show_shell_version(ver:i32);
- fn glob_pattern_p(pattern:*const c_char) -> i32;
- fn zcatfd(fd : i32 ,id : i32, nn :*mut c_char) -> i32;
- fn zmapfd(fd : i32, name :*mut *mut libc::c_char, nn: *mut libc::c_char) -> i32;
- fn sh_builtin_func_t(list :*mut WordList) -> i32;
- fn builtin_address_internal(comand_name:*mut c_char, i:i32) -> *mut builtin;
- fn termsig_handler (sig:i32);
+ fn show_shell_version(ver: i32);
+ fn glob_pattern_p(pattern: *const c_char) -> i32;
+ fn zcatfd(fd: i32, id: i32, nn: *mut c_char) -> i32;
+ fn zmapfd(fd: i32, name: *mut *mut libc::c_char, nn: *mut libc::c_char) -> i32;
+ fn sh_builtin_func_t(list: *mut WordList) -> i32;
+ fn builtin_address_internal(comand_name: *mut c_char, i: i32) -> *mut builtin;
+ fn termsig_handler(sig: i32);
fn throw_to_top_level();
fn default_columns() -> usize;
- fn wcsnwidth (chaa : * mut libc::wchar_t, size :i32, i: i32) -> i32;
- fn xstrmatch (string1 : * mut libc::c_char, string2 : * mut libc::c_char, i : libc::c_char) -> libc::c_char;
- fn open(pathname : *const libc::c_char, oflag : i32) -> i32;
- fn wcwidth( c :libc::wchar_t) -> i32;
- static mut loptend:*mut WordList;
- static bash_copyright : *const c_char;
- static bash_license : *const c_char;
- static mut terminating_signal:i32;
- static this_command_name:*mut libc::c_char;
- static mut interrupt_state:i32;
- static mut num_shell_builtins : i32;
- static mut static_shell_builtin : [builtin ; 100];
- static shell_builtins:*mut builtin;
- static mut current_builtin :*mut builtin;
+ fn wcsnwidth(chaa: *mut libc::wchar_t, size: i32, i: i32) -> i32;
+ fn xstrmatch(
+ string1: *mut libc::c_char,
+ string2: *mut libc::c_char,
+ i: libc::c_char,
+ ) -> libc::c_char;
+ fn open(pathname: *const libc::c_char, oflag: i32) -> i32;
+ fn wcwidth(c: libc::wchar_t) -> i32;
+ static mut loptend: *mut WordList;
+ static bash_copyright: *const c_char;
+ static bash_license: *const c_char;
+ static mut terminating_signal: i32;
+ static this_command_name: *mut libc::c_char;
+ static mut interrupt_state: i32;
+ static mut num_shell_builtins: i32;
+ static mut static_shell_builtin: [builtin; 100];
+ static shell_builtins: *mut builtin;
+ static mut current_builtin: *mut builtin;
}
#[no_mangle]
-pub extern "C" fn r_help_builtin(mut list:*mut WordList)->i32 {
- // let mut i:i32;
- let mut plen:usize;
- let mut match_found:i32;
- let mut sflag :i32 = 0;
- let mut dflag : i32 = 0;
- let mut mflag : i32 = 0;
+pub extern "C" fn r_help_builtin(mut list: *mut WordList) -> i32 {
+ // let mut i:i32;
+ let mut plen: usize;
+ let mut _match_found: i32;
+ let mut sflag: i32 = 0;
+ let mut dflag: i32 = 0;
+ let mut mflag: i32 = 0;
let mut m: bool;
- let pass:i32 = 0;
- let mut this_found:i32;
- let mut pattern:*mut c_char;
- let mut name:*mut c_char;
- let l:*mut WordList= list;
- let mut i : i32;
+ let _pass: i32 = 0;
+ let mut _this_found: i32;
+ let mut _pattern: *mut c_char;
+ let mut _name: *mut c_char;
+ let _l: *mut WordList = list;
+ let mut i: i32;
unsafe {
reset_internal_getopt();
}
let c_str_dms = CString::new("dms").unwrap(); // from a &str, creates a new allocation
- unsafe {
- i = internal_getopt (list, c_str_dms.as_ptr() as * mut c_char);
- }
+ unsafe {
+ i = internal_getopt(list, c_str_dms.as_ptr() as *mut c_char);
+ }
while i != -1 {
- let optu8:u8= i as u8;
- let optChar:char=char::from(optu8);
- match optChar{
- 'd'=> {dflag = 1; }
- 'm'=> {mflag = 1; }
- 's'=> {sflag = 1; }
- _=>{
- unsafe {
- if i == -99 {
+ let optu8: u8 = i as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'd' => {
+ dflag = 1;
+ }
+ 'm' => {
+ mflag = 1;
+ }
+ 's' => {
+ sflag = 1;
+ }
+ _ => unsafe {
+ if i == -99 {
r_builtin_help();
return EX_USAGE;
- }
- builtin_usage ();
- return EX_USAGE;
}
- }
- }
- unsafe{
- i = internal_getopt (list, c_str_dms.as_ptr() as * mut c_char);
+ builtin_usage();
+ return EX_USAGE;
+ },
+ }
+ unsafe {
+ i = internal_getopt(list, c_str_dms.as_ptr() as *mut c_char);
}
}
- if list == std::ptr::null_mut(){
- unsafe {
- show_shell_version (0);
- }
- show_builtin_command_help ();
- return EXECUTION_SUCCESS!();
+ if list == std::ptr::null_mut() {
+ unsafe {
+ show_shell_version(0);
+ }
+ show_builtin_command_help();
+ return EXECUTION_SUCCESS!();
}
- unsafe {
- let mut pattern = 0;
- pattern = glob_pattern_p ((*(*list).word).word);
- if pattern == 1 {
- println!("Shell commands matching keyword, Shell commands matching keyword");
- if list != std::ptr::null_mut() && (*list).next !=std::ptr::null_mut() {
- println!("Shell commands matching keywords");
- }
- else {
- println!("Shell commands matching keyword");
- }
- println!("{:?} ,",list);
- }
- // let mut loptendt=*list;
-
- let mut match_found = 0;
- let mut pattern:*mut c_char = 0 as *mut libc::c_char;
- while list !=std::ptr::null_mut() {
- pattern = (*(*list).word).word;
- plen = libc::strlen (pattern);
- let mut this_found = 0;
- let mut v : Vec<*mut libc::c_char> = Vec::new();
- for val in 0..=75 {
- //let nname = &shell_builtins[val].name;
- let builtin1 = unsafe{&(*((shell_builtins as usize + (val*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
- if builtin1.name != std::ptr::null_mut(){
- v.push(builtin1.name);
- }
- }
- for val in 1..3 {
- //for &mut namee in &mut v {
- for i in 0..v.len(){
- QUIT();
- /* First val: look for exact string or pattern matches.
- Second val: look for prefix matches like bash-4.2 */
- if val == 1{
- m = (libc::strcmp (pattern,v[i]) == 0)||
- (strmatch (pattern,v[i], FNMATCH_EXTFLAG!()) != FNM_NOMATCH!());
- }
- else{
- m = libc::strncmp (pattern, v[i], plen) == 0;
- }
- if m {
- this_found = 1;
- match_found = match_found +1 ;
- if dflag == 1{
- show_desc (i as i32);
- continue;
- }
- else if mflag ==1{
- show_manpage (v[i], i as i32);
- continue;
+ unsafe {
+ let mut pattern = 0;
+ pattern = glob_pattern_p((*(*list).word).word);
+ if pattern == 1 {
+ println!("Shell commands matching keyword, Shell commands matching keyword");
+ if list != std::ptr::null_mut() && (*list).next != std::ptr::null_mut() {
+ println!("Shell commands matching keywords");
+ } else {
+ println!("Shell commands matching keyword");
+ }
+ println!("{:?} ,", list);
+ }
+ // let mut loptendt=*list;
+
+ let mut match_found = 0;
+ let mut pattern: *mut c_char = 0 as *mut libc::c_char;
+ while list != std::ptr::null_mut() {
+ pattern = (*(*list).word).word;
+ plen = libc::strlen(pattern);
+ let mut this_found = 0;
+ let mut v: Vec<*mut libc::c_char> = Vec::new();
+ for val in 0..=75 {
+ //let nname = &shell_builtins[val].name;
+ let builtin1 = unsafe {
+ &(*((shell_builtins as usize + (val * BUILTIN_SIZEOF!()) as usize)
+ as *mut builtin))
+ };
+ if builtin1.name != std::ptr::null_mut() {
+ v.push(builtin1.name);
+ }
+ }
+ for val in 1..3 {
+ //for &mut namee in &mut v {
+ for i in 0..v.len() {
+ QUIT();
+ /* First val: look for exact string or pattern matches.
+ Second val: look for prefix matches like bash-4.2 */
+ if val == 1 {
+ m = (libc::strcmp(pattern, v[i]) == 0)
+ || (strmatch(pattern, v[i], FNMATCH_EXTFLAG!()) != FNM_NOMATCH!());
+ } else {
+ m = libc::strncmp(pattern, v[i], plen) == 0;
}
- let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
- print!("{:?}:",CStr::from_ptr(builtin1.name));
- show_helpsynopsis(i as i32);
- if sflag == 0{
- show_longdoc(i as i32);
- }
+ if m {
+ this_found = 1;
+ match_found = match_found + 1;
+ if dflag == 1 {
+ show_desc(i as i32);
+ continue;
+ } else if mflag == 1 {
+ show_manpage(v[i], i as i32);
+ continue;
+ }
+ let builtin1 = unsafe {
+ &(*((shell_builtins as usize + (i * BUILTIN_SIZEOF!()) as usize)
+ as *mut builtin))
+ };
+ print!("{:?}:", CStr::from_ptr(builtin1.name));
+ show_helpsynopsis(i as i32);
+ if sflag == 0 {
+ show_longdoc(i as i32);
+ }
+ }
+ }
+ if val == 1 && this_found == 1 {
+ break;
}
- }
- if val == 1 && this_found == 1{
- break;
- }
- }
- if (*list).next != std::ptr::null_mut(){
- list = (*list).next;
-
- }
- else {
-
- break;
- }
- }
- if match_found == 0{
- let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
- let resources = vec![ "message.ftl".into()];
- let mut args = FluentArgs::new();
- let s1 = String::from("command");
- args.set("name",format!("{:?}",CStr::from_ptr(pattern)));
- let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message("helperr").unwrap();
- let mut pattern = value.value().expect("partern err");
- let mut errors = vec![];
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
- println!("utshell: help: {}", msg1);
- return EXECUTION_FAILURE!();
+ }
+ if (*list).next != std::ptr::null_mut() {
+ list = (*list).next;
+ } else {
+ break;
+ }
+ }
+ if match_found == 0 {
+ let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
+ let resources = vec!["message.ftl".into()];
+ let mut args = FluentArgs::new();
+ let _s1 = String::from("command");
+ args.set("name", format!("{:?}", CStr::from_ptr(pattern)));
+ let bundle = mgr.get_bundle(get_local_str(), resources);
+ let value = bundle.get_message("helperr").unwrap();
+ let pattern = value.value().expect("partern err");
+ let mut errors = vec![];
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ println!("utshell: help: {}", msg1);
+ return EXECUTION_FAILURE!();
+ }
+ }
+ unsafe {
+ std::io::stdout().flush();
}
- }
- unsafe {
- std::io::stdout().flush();
- }
- return EXECUTION_SUCCESS!();
+ return EXECUTION_SUCCESS!();
}
-
#[no_mangle]
-pub extern "C" fn r_help_null_builtin (mut list:*mut WordList) -> i32{
- unsafe {
- show_shell_version(0);
- }
- show_builtin_command_help ();
- return EXECUTION_SUCCESS!();
+pub extern "C" fn r_help_null_builtin(_list: *mut WordList) -> i32 {
+ unsafe {
+ show_shell_version(0);
+ }
+ show_builtin_command_help();
+ return EXECUTION_SUCCESS!();
}
-unsafe fn QUIT ()
-{
- if terminating_signal !=0 {
- termsig_handler (terminating_signal);
- }
+unsafe fn QUIT() {
+ if terminating_signal != 0 {
+ termsig_handler(terminating_signal);
+ }
- if interrupt_state !=0{
- throw_to_top_level();
- }
+ if interrupt_state != 0 {
+ throw_to_top_level();
+ }
}
-pub extern "C" fn r_builtin_help (){
+pub extern "C" fn r_builtin_help() {
// print all command usage
let mut ind: i32 = 5;
let d: i32;
unsafe {
current_builtin = builtin_address_internal(this_command_name, 0);
- if current_builtin == 0 as *mut builtin{
- return ;
- }
+ if current_builtin == 0 as *mut builtin {
+ return;
+ }
- d = (current_builtin as usize - shell_builtins as usize) as i32;
+ d = (current_builtin as usize - shell_builtins as usize) as i32;
}
- ind = d/BUILTIN_SIZEOF!() ;
+ ind = d / BUILTIN_SIZEOF!();
unsafe {
- print!("{:?} : ",CStr::from_ptr(this_command_name));
+ print!("{:?} : ", CStr::from_ptr(this_command_name));
}
show_helpsynopsis(ind);
- show_longdoc (ind);
+ show_longdoc(ind);
}
-fn open_helpfile(name :*mut c_char) -> i32{
-
- let mut fd : i32;
+fn open_helpfile(name: *mut c_char) -> i32 {
+ let fd: i32;
unsafe {
- fd = open (name, 0);
-
+ fd = open(name, 0);
}
if fd == -1 {
return -1;
- }
- else {
- fd
+ } else {
+ fd
}
}
-fn show_longdoc(i : i32){
- let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
- let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
- let resources = vec![ "message.ftl".into()];
- let mut args = FluentArgs::new();
- let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) };
- let s1 = String::from("command");
- match i {
- 0|1|2|3|4|5 => {
- args.set("cmdName",format!("{}{}",s1,i));}
- 33 => {
- args.set("cmdName",format!("{}{}",s1,6))}
- 75 => {
- args.set("cmdName",format!("{}{}",s1,7))}
- _ => {
- let msg: &str = c_str.to_str().unwrap();
- args.set("cmdName",msg);}
- }
+fn show_longdoc(i: i32) {
+ let builtin1 = unsafe {
+ &(*((shell_builtins as usize + (i * BUILTIN_SIZEOF!()) as usize) as *mut builtin))
+ };
+ let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
+ let resources = vec!["message.ftl".into()];
+ let mut args = FluentArgs::new();
+ let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) };
+ let s1 = String::from("command");
+ match i {
+ 0 | 1 | 2 | 3 | 4 | 5 => {
+ args.set("cmdName", format!("{}{}", s1, i));
+ }
+ 33 => args.set("cmdName", format!("{}{}", s1, 6)),
+ 75 => args.set("cmdName", format!("{}{}", s1, 7)),
+ _ => {
+ let msg: &str = c_str.to_str().unwrap();
+ args.set("cmdName", msg);
+ }
+ }
let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message("helplongdoc").unwrap();
- let mut pattern = value.value().expect("partern err");
+ let value = bundle.get_message("helplongdoc").unwrap();
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
- println!(" {}", msg1);
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ println!(" {}", msg1);
}
-fn show_helpsynopsis( i : i32)
-{
- let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
+fn show_helpsynopsis(i: i32) {
+ let builtin1 = unsafe {
+ &(*((shell_builtins as usize + (i * BUILTIN_SIZEOF!()) as usize) as *mut builtin))
+ };
let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
- let resources = vec![ "message.ftl".into()];
+ let resources = vec!["message.ftl".into()];
let mut args = FluentArgs::new();
let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) };
let s1 = String::from("command");
match i {
- 0|1|2|3|4|5 => {
- args.set("cmdName",format!("{}{}",s1,i));}
- 33 => {
- args.set("cmdName",format!("{}{}",s1,6))}
- 75 => {
- args.set("cmdName",format!("{}{}",s1,7))}
- _ => {
- let msg: &str = c_str.to_str().unwrap();
- args.set("cmdName",msg);}
- }
+ 0 | 1 | 2 | 3 | 4 | 5 => {
+ args.set("cmdName", format!("{}{}", s1, i));
+ }
+ 33 => args.set("cmdName", format!("{}{}", s1, 6)),
+ 75 => args.set("cmdName", format!("{}{}", s1, 7)),
+ _ => {
+ let msg: &str = c_str.to_str().unwrap();
+ args.set("cmdName", msg);
+ }
+ }
let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message("helpsynopsis").unwrap();
- let mut pattern = value.value().expect("partern err");
+ let value = bundle.get_message("helpsynopsis").unwrap();
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
- println!(" {}", msg1);
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ println!(" {}", msg1);
}
-fn show_desc (i :i32){
- let builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
- let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
- let resources = vec![ "message.ftl".into()];
- let mut args = FluentArgs::new();
- let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) };
- let s1 = String::from("command");
- match i {
- 0|1|2|3|4|5 => {
- args.set("cmdName",format!("{}{}",s1,i));}
- 33 => {
- args.set("cmdName",format!("{}{}",s1,6))}
- 75 => {
- args.set("cmdName",format!("{}{}",s1,7))}
- _ => {
- let msg: &str = c_str.to_str().unwrap();
- args.set("cmdName",msg);}
- }
- let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message("helpname").unwrap();
- let mut pattern = value.value().expect("partern err");
- let mut errors = vec![];
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
- println!(" {}", msg1);
+fn show_desc(i: i32) {
+ let builtin1 = unsafe {
+ &(*((shell_builtins as usize + (i * BUILTIN_SIZEOF!()) as usize) as *mut builtin))
+ };
+ let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
+ let resources = vec!["message.ftl".into()];
+ let mut args = FluentArgs::new();
+ let c_str: &CStr = unsafe { CStr::from_ptr(builtin1.name) };
+ let s1 = String::from("command");
+ match i {
+ 0 | 1 | 2 | 3 | 4 | 5 => {
+ args.set("cmdName", format!("{}{}", s1, i));
+ }
+ 33 => args.set("cmdName", format!("{}{}", s1, 6)),
+ 75 => args.set("cmdName", format!("{}{}", s1, 7)),
+ _ => {
+ let msg: &str = c_str.to_str().unwrap();
+ args.set("cmdName", msg);
+ }
+ }
+ let bundle = mgr.get_bundle(get_local_str(), resources);
+ let value = bundle.get_message("helpname").unwrap();
+ let pattern = value.value().expect("partern err");
+ let mut errors = vec![];
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ println!(" {}", msg1);
}
-fn show_manpage (name : *mut c_char, i : i32){
- /* NAME */
- println! ("NAME\n");
- show_desc(i);
-
- /* SYNOPSIS */
- println! ("SYNOPSIS\n");
- show_helpsynopsis(i);
- println! ("DESCRIPTION\n");
- show_longdoc(i);
- /* SEE ALSO */
- println! ("SEE ALSO\n");
- println! (" utshell(1) {} \n\n"," ");
-
- /* IMPLEMENTATION */
- println! ("IMPLEMENTATION\n");
- println! (" ");
- unsafe {
- show_shell_version (0);
- }
- println! (" ");
- unsafe {
- println! ("{:?}", CStr::from_ptr(bash_copyright));
- }
- println! (" ");
- unsafe {
- println! ("{:?}", CStr::from_ptr(bash_license));
- }
+fn show_manpage(_name: *mut c_char, i: i32) {
+ /* NAME */
+ println!("NAME\n");
+ show_desc(i);
+
+ /* SYNOPSIS */
+ println!("SYNOPSIS\n");
+ show_helpsynopsis(i);
+ println!("DESCRIPTION\n");
+ show_longdoc(i);
+ /* SEE ALSO */
+ println!("SEE ALSO\n");
+ println!(" utshell(1) {} \n\n", " ");
+
+ /* IMPLEMENTATION */
+ println!("IMPLEMENTATION\n");
+ println!(" ");
+ unsafe {
+ show_shell_version(0);
+ }
+ println!(" ");
+ unsafe {
+ println!("{:?}", CStr::from_ptr(bash_copyright));
+ }
+ println!(" ");
+ unsafe {
+ println!("{:?}", CStr::from_ptr(bash_license));
+ }
}
#[no_mangle]
-pub extern "C" fn dispcolumn (i : i32, buf : *mut c_char, bufsize :libc::c_int, width : usize, height : i32){
- let mut j : i32;
- let mut dispcols : usize;
- let mut helpdoc :*mut libc::c_char;
- /* first column */
- let mut builtin1 = unsafe{&(*((shell_builtins as usize + (i*BUILTIN_SIZEOF!()) as usize) as *mut builtin))};
+pub extern "C" fn dispcolumn(
+ i: i32,
+ buf: *mut c_char,
+ _bufsize: libc::c_int,
+ width: usize,
+ height: i32,
+) {
+ let mut _j: i32;
+ let dispcols: usize;
+ let mut helpdoc: *mut libc::c_char;
+ /* first column */
+ let mut builtin1 = unsafe {
+ &(*((shell_builtins as usize + (i * BUILTIN_SIZEOF!()) as usize) as *mut builtin))
+ };
helpdoc = builtin1.short_doc;
unsafe {
- libc::strncpy (((buf as usize + 4 as usize ) as * mut c_char), helpdoc, width - 2);
- *((buf as usize + (width - 2) as usize) as * mut c_char)='>' as c_char;
- *((buf as usize+(width - 1) as usize) as * mut c_char)='\0' as c_char;
- }
+ libc::strncpy(
+ (buf as usize + 4 as usize) as *mut c_char,
+ helpdoc,
+ width - 2,
+ );
+ *((buf as usize + (width - 2) as usize) as *mut c_char) = '>' as c_char;
+ *((buf as usize + (width - 1) as usize) as *mut c_char) = '\0' as c_char;
+ }
/* indicate truncation */
- println! ("{:?}", buf);
+ println!("{:?}", buf);
unsafe {
- if ((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins){
- println! ("\n");
- return;
- }
+ if ((i << 1) >= num_shell_builtins) || (i + height >= num_shell_builtins) {
+ println!("\n");
+ return;
+ }
}
- dispcols = unsafe {libc::strlen(buf)};
+ dispcols = unsafe { libc::strlen(buf) };
/* two spaces */
- for j in dispcols .. width{
- std::io::stdout().write(b" ");
- }
- /* second column */
- builtin1 = unsafe{&(*((shell_builtins as usize + (((i+height)*BUILTIN_SIZEOF!()) as usize)) as *mut builtin))};
- helpdoc = builtin1.short_doc as *mut libc::c_char;
- unsafe {
- if builtin1.flags && BUILTIN_ENABLED!()==1 {
- *((buf as usize) as * mut c_char)=' ' as c_char;
- }
- else{
- *((buf as usize) as * mut c_char)='*' as c_char;
- }
- libc::strncpy (((buf as usize + 4 as usize ) as * mut c_char), helpdoc, width - 3);
- *((buf as usize + (width - 3) as usize) as * mut c_char)='>' as c_char;
- *((buf as usize+(width - 2) as usize) as * mut c_char)='\0' as c_char;
- }
- println! ("{:?}\n", buf);
+ for _j in dispcols..width {
+ std::io::stdout().write(b" ");
+ }
+ /* second column */
+ builtin1 = unsafe {
+ &(*((shell_builtins as usize + (((i + height) * BUILTIN_SIZEOF!()) as usize))
+ as *mut builtin))
+ };
+ helpdoc = builtin1.short_doc as *mut libc::c_char;
+ unsafe {
+ if builtin1.flags && BUILTIN_ENABLED!() == 1 {
+ *((buf as usize) as *mut c_char) = ' ' as c_char;
+ } else {
+ *((buf as usize) as *mut c_char) = '*' as c_char;
+ }
+ libc::strncpy(
+ (buf as usize + 4 as usize) as *mut c_char,
+ helpdoc,
+ width - 3,
+ );
+ *((buf as usize + (width - 3) as usize) as *mut c_char) = '>' as c_char;
+ *((buf as usize + (width - 2) as usize) as *mut c_char) = '\0' as c_char;
+ }
+ println!("{:?}\n", buf);
}
-pub fn wdispcolumn (i : i32, buf :*mut c_char, bufsize : i32, width : i32, height : i32){
- let mut j : i32;
+pub fn wdispcolumn(i: i32, _buf: *mut c_char, _bufsize: i32, _width: i32, _height: i32) {
+ let mut _j: i32;
show_helpsynopsis(i);
}
-fn show_builtin_command_help (){
- let mut i : i32;
- let mut j : i32;
- let height : i32 = 76;
- let mut width : usize;
- let mut t :*mut libc::c_char;
- let mut blurb:[libc::c_char;128] = ['0' as libc::c_char;128];
+fn show_builtin_command_help() {
+ let mut _i: i32;
+ let mut _j: i32;
+ let height: i32 = 76;
+ let mut width: usize;
+ let mut _t: *mut libc::c_char;
+ let mut blurb: [libc::c_char; 128] = ['0' as libc::c_char; 128];
let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
let resources = vec!["message.ftl".into()];
let bundle = mgr.get_bundle(get_local_str(), resources);
let value = bundle.get_message("information").unwrap();
- let pattern = value.value().expect("partern err");
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
let msg1 = bundle.format_pattern(&pattern, None, &mut errors);
println!("{}\n", msg1);
//println!("{}",("These shell commands are defined internally. Type `help' to see this list.\n Type `help name' to find out more about the function `name'.\n Use `info bash' to find out more about the shell in general.\n Use `man -k' or `info' to find out more about commands not in this list.\n A star (*) next to a name means that the command is disabled.\n"));
- let ref2: &mut libc::c_char= &mut blurb[0];
+ let ref2: &mut libc::c_char = &mut blurb[0];
unsafe {
- width = default_columns();
- }
- width /= 2;
- if width > (std::mem::size_of::()*128) {
- width = std::mem::size_of::()*128;
- }
- if width <= 3{
- width = 40;
- }
- for i in 0..height{
- unsafe {
- QUIT();
- }
- if MB_CUR_MAX!() > 1 {
- let ptr2: *mut libc::c_char = ref2 as *mut libc::c_char;
- wdispcolumn (i, ptr2,128, width as i32, height);
- }
-}
+ width = default_columns();
+ }
+ width /= 2;
+ if width > (std::mem::size_of::() * 128) {
+ width = std::mem::size_of::() * 128;
+ }
+ if width <= 3 {
+ width = 40;
+ }
+ for i in 0..height {
+ unsafe {
+ QUIT();
+ }
+ if MB_CUR_MAX!() > 1 {
+ let ptr2: *mut libc::c_char = ref2 as *mut libc::c_char;
+ wdispcolumn(i, ptr2, 128, width as i32, height);
+ }
+ }
}
//#endif /* HELP_BUILTIN */
-fn strmatch (pattern : *mut libc::c_char, string : *mut libc::c_char, flags : libc::c_char) -> libc::c_char
-{
- if ((string as usize)as * mut c_char != std::ptr::null_mut()) || ((pattern as usize)as * mut c_char != std::ptr::null_mut()){
- return FNM_NOMATCH!();
- }
- return unsafe {xstrmatch (pattern, string, flags)};
+fn strmatch(
+ pattern: *mut libc::c_char,
+ string: *mut libc::c_char,
+ flags: libc::c_char,
+) -> libc::c_char {
+ if ((string as usize) as *mut c_char != std::ptr::null_mut())
+ || ((pattern as usize) as *mut c_char != std::ptr::null_mut())
+ {
+ return FNM_NOMATCH!();
+ }
+ return unsafe { xstrmatch(pattern, string, flags) };
}
struct Thing {
- pointer_to_self: *mut Thing,
+ pointer_to_self: *mut Thing,
}
-fn xmalloc (size:usize) ->*mut c_void {
- let ret: *mut c_void;
-unsafe {
- ret = libc::malloc(size);
+fn xmalloc(size: usize) -> *mut c_void {
+ let ret: *mut c_void;
+ unsafe {
+ ret = libc::malloc(size);
+ }
+ // if (ret == 0) {
+ // println!("man2html: out of memory");
+ // // fprintf(stderr, "man2html: out of memory");
+ // (1)
+ // }
+ ret
}
-// if (ret == 0) {
-// println!("man2html: out of memory");
-// // fprintf(stderr, "man2html: out of memory");
-// (1)
-// }
- ret
-}
// fn wcswidth(pwcs : *mut libc::wchar_t , n : i32) -> i32{
// let mut wc : libc::wchar_t;
// let mut len : i32 = 0;
// let mut l : i32;
-
+
// while n-1 > 0 && *(pwcs as usize + 1 as usize) != '\0' as libc::wchar_t{
// wc = *(pwcs += 1);
// if wcwidth(wc) < 0 {
diff --git a/bash-5.1/builtins_rust/history/src/glob.rs b/bash-5.1/builtins_rust/history/src/glob.rs
new file mode 100644
index 0000000000000000000000000000000000000000..54fc192201088d2d56e31be0fe781df4188402d2
--- /dev/null
+++ b/bash-5.1/builtins_rust/history/src/glob.rs
@@ -0,0 +1,4200 @@
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+
+//# SPDX-License-Identifier: GPL-3.0-or-later
+
+/* automatically generated by rust-bindgen */
+
+pub const __EXTENSIONS__: u32 = 1;
+pub const _ALL_SOURCE: u32 = 1;
+pub const _GNU_SOURCE: u32 = 1;
+pub const _POSIX_PTHREAD_SEMANTICS: u32 = 1;
+pub const _TANDEM_SOURCE: u32 = 1;
+pub const JOB_CONTROL: u32 = 1;
+pub const ALIAS: u32 = 1;
+pub const PUSHD_AND_POPD: u32 = 1;
+pub const BRACE_EXPANSION: u32 = 1;
+pub const READLINE: u32 = 1;
+pub const BANG_HISTORY: u32 = 1;
+pub const HISTORY: u32 = 1;
+pub const HELP_BUILTIN: u32 = 1;
+pub const RESTRICTED_SHELL: u32 = 1;
+pub const PROCESS_SUBSTITUTION: u32 = 1;
+pub const PROMPT_STRING_DECODE: u32 = 1;
+pub const SELECT_COMMAND: u32 = 1;
+pub const COMMAND_TIMING: u32 = 1;
+pub const ARRAY_VARS: u32 = 1;
+pub const DPAREN_ARITHMETIC: u32 = 1;
+pub const EXTENDED_GLOB: u32 = 1;
+pub const EXTGLOB_DEFAULT: u32 = 0;
+pub const COND_COMMAND: u32 = 1;
+pub const COND_REGEXP: u32 = 1;
+pub const COPROCESS_SUPPORT: u32 = 1;
+pub const ARITH_FOR_COMMAND: u32 = 1;
+pub const NETWORK_REDIRECTIONS: u32 = 1;
+pub const PROGRAMMABLE_COMPLETION: u32 = 1;
+pub const DEBUGGER: u32 = 1;
+pub const MEMSCRAMBLE: u32 = 1;
+pub const CASEMOD_ATTRS: u32 = 1;
+pub const CASEMOD_EXPANSIONS: u32 = 1;
+pub const GLOBASCII_DEFAULT: u32 = 1;
+pub const FUNCTION_IMPORT: u32 = 1;
+pub const ENABLE_NLS: u32 = 1;
+pub const DEFAULT_PATH_VALUE: &'static [u8; 63usize] =
+ b"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.\0";
+pub const STANDARD_UTILS_PATH: &'static [u8; 30usize] = b"/bin:/usr/bin:/usr/sbin:/sbin\0";
+pub const PPROMPT: &'static [u8; 11usize] = b"\\s-\\\\v\\\\$ \0";
+pub const SPROMPT: &'static [u8; 3usize] = b"> \0";
+pub const DEFAULT_BASHRC: &'static [u8; 10usize] = b"~/.bashrc\0";
+pub const SYS_BASH_LOGOUT: &'static [u8; 22usize] = b"/etc/bash.bash_logout\0";
+pub const MULTIPLE_COPROCS: u32 = 0;
+pub const CHECKWINSIZE_DEFAULT: u32 = 1;
+pub const OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT: u32 = 1;
+pub const CHECKHASH_DEFAULT: u32 = 0;
+pub const EVALNEST_MAX: u32 = 0;
+pub const SOURCENEST_MAX: u32 = 0;
+pub const OLDPWD_CHECK_DIRECTORY: u32 = 1;
+pub const HISTEXPAND_DEFAULT: u32 = 1;
+pub const ASSOC_KVPAIR_ASSIGNMENT: u32 = 1;
+pub const HAVE_STRINGIZE: u32 = 1;
+pub const HAVE_LONG_DOUBLE: u32 = 1;
+pub const PROTOTYPES: u32 = 1;
+pub const __PROTOTYPES: u32 = 1;
+pub const HAVE_LONG_LONG: u32 = 1;
+pub const HAVE_UNSIGNED_LONG_LONG: u32 = 1;
+pub const SIZEOF_INT: u32 = 4;
+pub const SIZEOF_LONG: u32 = 8;
+pub const SIZEOF_CHAR_P: u32 = 8;
+pub const SIZEOF_DOUBLE: u32 = 8;
+pub const SIZEOF_INTMAX_T: u32 = 8;
+pub const SIZEOF_LONG_LONG: u32 = 8;
+pub const SIZEOF_WCHAR_T: u32 = 4;
+pub const DEFAULT_MAIL_DIRECTORY: &'static [u8; 10usize] = b"/var/mail\0";
+pub const STDC_HEADERS: u32 = 1;
+pub const HAVE_ALLOCA: u32 = 1;
+pub const HAVE_ALLOCA_H: u32 = 1;
+pub const MAJOR_IN_SYSMACROS: u32 = 1;
+pub const HAVE_MBSTATE_T: u32 = 1;
+pub const HAVE_QUAD_T: u32 = 1;
+pub const HAVE_WCHAR_T: u32 = 1;
+pub const HAVE_WCTYPE_T: u32 = 1;
+pub const HAVE_WINT_T: u32 = 1;
+pub const HAVE_DECL_SYS_SIGLIST: u32 = 1;
+pub const UNDER_SYS_SIGLIST_DECLARED: u32 = 1;
+pub const HAVE_SYS_SIGLIST: u32 = 1;
+pub const HAVE_UNDER_SYS_SIGLIST: u32 = 1;
+pub const HAVE_SYS_ERRLIST: u32 = 1;
+pub const HAVE_STRUCT_DIRENT_D_INO: u32 = 1;
+pub const HAVE_STRUCT_DIRENT_D_FILENO: u32 = 1;
+pub const FIONREAD_IN_SYS_IOCTL: u32 = 1;
+pub const GWINSZ_IN_SYS_IOCTL: u32 = 1;
+pub const STRUCT_WINSIZE_IN_SYS_IOCTL: u32 = 1;
+pub const TERMIOS_LDISC: u32 = 1;
+pub const TERMIO_LDISC: u32 = 1;
+pub const HAVE_STRUCT_STAT_ST_BLOCKS: u32 = 1;
+pub const HAVE_STRUCT_TM_TM_ZONE: u32 = 1;
+pub const HAVE_TM_ZONE: u32 = 1;
+pub const HAVE_TIMEVAL: u32 = 1;
+pub const HAVE_STRUCT_TIMEZONE: u32 = 1;
+pub const WEXITSTATUS_OFFSET: u32 = 8;
+pub const HAVE_STRUCT_TIMESPEC: u32 = 1;
+pub const TIME_H_DEFINES_STRUCT_TIMESPEC: u32 = 1;
+pub const HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC: u32 = 1;
+pub const TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC: u32 = 1;
+pub const HAVE_GETPW_DECLS: u32 = 1;
+pub const HAVE_DECL_AUDIT_USER_TTY: u32 = 1;
+pub const HAVE_DECL_CONFSTR: u32 = 1;
+pub const HAVE_DECL_PRINTF: u32 = 1;
+pub const HAVE_DECL_SBRK: u32 = 1;
+pub const HAVE_DECL_STRCPY: u32 = 1;
+pub const HAVE_DECL_STRSIGNAL: u32 = 1;
+pub const HAVE_DECL_STRTOLD: u32 = 1;
+pub const HAVE_DECL_STRTOIMAX: u32 = 1;
+pub const HAVE_DECL_STRTOL: u32 = 1;
+pub const HAVE_DECL_STRTOLL: u32 = 1;
+pub const HAVE_DECL_STRTOUL: u32 = 1;
+pub const HAVE_DECL_STRTOULL: u32 = 1;
+pub const HAVE_DECL_STRTOUMAX: u32 = 1;
+pub const GETPGRP_VOID: u32 = 1;
+pub const PGRP_PIPE: u32 = 1;
+pub const ULIMIT_MAXFDS: u32 = 1;
+pub const CAN_REDEFINE_GETENV: u32 = 1;
+pub const HAVE_STD_PUTENV: u32 = 1;
+pub const HAVE_STD_UNSETENV: u32 = 1;
+pub const HAVE_PRINTF_A_FORMAT: u32 = 1;
+pub const HAVE_LANGINFO_CODESET: u32 = 1;
+pub const HAVE_HASH_BANG_EXEC: u32 = 1;
+pub const HAVE_DEV_FD: u32 = 1;
+pub const DEV_FD_PREFIX: &'static [u8; 9usize] = b"/dev/fd/\0";
+pub const HAVE_DEV_STDIN: u32 = 1;
+pub const VOID_SIGHANDLER: u32 = 1;
+pub const HAVE_POSIX_SIGNALS: u32 = 1;
+pub const HAVE_ASPRINTF: u32 = 1;
+pub const HAVE_BCOPY: u32 = 1;
+pub const HAVE_BZERO: u32 = 1;
+pub const HAVE_CHOWN: u32 = 1;
+pub const HAVE_CONFSTR: u32 = 1;
+pub const HAVE_DLCLOSE: u32 = 1;
+pub const HAVE_DLOPEN: u32 = 1;
+pub const HAVE_DLSYM: u32 = 1;
+pub const HAVE_DPRINTF: u32 = 1;
+pub const HAVE_DUP2: u32 = 1;
+pub const HAVE_EACCESS: u32 = 1;
+pub const HAVE_FACCESSAT: u32 = 1;
+pub const HAVE_FCNTL: u32 = 1;
+pub const HAVE_FNMATCH: u32 = 1;
+pub const FNMATCH_EQUIV_FALLBACK: u32 = 1;
+pub const HAVE___FPURGE: u32 = 1;
+pub const HAVE_DECL_FPURGE: u32 = 0;
+pub const HAVE_GETADDRINFO: u32 = 1;
+pub const HAVE_GETCWD: u32 = 1;
+pub const HAVE_GETENTROPY: u32 = 1;
+pub const HAVE_GETDTABLESIZE: u32 = 1;
+pub const HAVE_GETGROUPS: u32 = 1;
+pub const HAVE_GETHOSTBYNAME: u32 = 1;
+pub const HAVE_GETHOSTNAME: u32 = 1;
+pub const HAVE_GETPAGESIZE: u32 = 1;
+pub const HAVE_GETPEERNAME: u32 = 1;
+pub const HAVE_GETPWENT: u32 = 1;
+pub const HAVE_GETPWNAM: u32 = 1;
+pub const HAVE_GETPWUID: u32 = 1;
+pub const HAVE_GETRANDOM: u32 = 1;
+pub const HAVE_GETRLIMIT: u32 = 1;
+pub const HAVE_GETRUSAGE: u32 = 1;
+pub const HAVE_GETSERVBYNAME: u32 = 1;
+pub const HAVE_GETSERVENT: u32 = 1;
+pub const HAVE_GETTIMEOFDAY: u32 = 1;
+pub const HAVE_ICONV: u32 = 1;
+pub const HAVE_IMAXDIV: u32 = 1;
+pub const HAVE_INET_ATON: u32 = 1;
+pub const HAVE_ISASCII: u32 = 1;
+pub const HAVE_ISBLANK: u32 = 1;
+pub const HAVE_ISGRAPH: u32 = 1;
+pub const HAVE_ISPRINT: u32 = 1;
+pub const HAVE_ISSPACE: u32 = 1;
+pub const HAVE_ISWCTYPE: u32 = 1;
+pub const HAVE_ISWLOWER: u32 = 1;
+pub const HAVE_ISWUPPER: u32 = 1;
+pub const HAVE_ISXDIGIT: u32 = 1;
+pub const HAVE_KILL: u32 = 1;
+pub const HAVE_KILLPG: u32 = 1;
+pub const HAVE_LSTAT: u32 = 1;
+pub const HAVE_MBRLEN: u32 = 1;
+pub const HAVE_MBRTOWC: u32 = 1;
+pub const HAVE_MBSNRTOWCS: u32 = 1;
+pub const HAVE_MBSRTOWCS: u32 = 1;
+pub const HAVE_MEMMOVE: u32 = 1;
+pub const HAVE_MEMSET: u32 = 1;
+pub const HAVE_MKDTEMP: u32 = 1;
+pub const HAVE_MKFIFO: u32 = 1;
+pub const HAVE_MKSTEMP: u32 = 1;
+pub const HAVE_PATHCONF: u32 = 1;
+pub const HAVE_PSELECT: u32 = 1;
+pub const HAVE_PREAD: u32 = 1;
+pub const HAVE_PUTENV: u32 = 1;
+pub const HAVE_RAISE: u32 = 1;
+pub const HAVE_RANDOM: u32 = 1;
+pub const HAVE_READLINK: u32 = 1;
+pub const HAVE_REGCOMP: u32 = 1;
+pub const HAVE_REGEXEC: u32 = 1;
+pub const HAVE_RENAME: u32 = 1;
+pub const HAVE_SBRK: u32 = 1;
+pub const HAVE_SELECT: u32 = 1;
+pub const HAVE_SETENV: u32 = 1;
+pub const HAVE_SETITIMER: u32 = 1;
+pub const HAVE_SETLINEBUF: u32 = 1;
+pub const HAVE_SETLOCALE: u32 = 1;
+pub const HAVE_DECL_SETREGID: u32 = 1;
+pub const HAVE_SETRESGID: u32 = 1;
+pub const HAVE_SETRESUID: u32 = 1;
+pub const HAVE_SETVBUF: u32 = 1;
+pub const HAVE_SIGINTERRUPT: u32 = 1;
+pub const HAVE_POSIX_SIGSETJMP: u32 = 1;
+pub const HAVE_SNPRINTF: u32 = 1;
+pub const HAVE_STRCASECMP: u32 = 1;
+pub const HAVE_STRCASESTR: u32 = 1;
+pub const HAVE_STRCHR: u32 = 1;
+pub const HAVE_STRCHRNUL: u32 = 1;
+pub const HAVE_STRCOLL: u32 = 1;
+pub const HAVE_STRERROR: u32 = 1;
+pub const HAVE_STRFTIME: u32 = 1;
+pub const HAVE_STRNLEN: u32 = 1;
+pub const HAVE_STRPBRK: u32 = 1;
+pub const HAVE_STRSTR: u32 = 1;
+pub const HAVE_STRTOD: u32 = 1;
+pub const HAVE_STRTOIMAX: u32 = 1;
+pub const HAVE_STRTOL: u32 = 1;
+pub const HAVE_STRTOLL: u32 = 1;
+pub const HAVE_STRTOUL: u32 = 1;
+pub const HAVE_STRTOULL: u32 = 1;
+pub const HAVE_STRTOUMAX: u32 = 1;
+pub const HAVE_STRSIGNAL: u32 = 1;
+pub const HAVE_SYSCONF: u32 = 1;
+pub const HAVE_SYSLOG: u32 = 1;
+pub const HAVE_TCGETATTR: u32 = 1;
+pub const HAVE_TCGETPGRP: u32 = 1;
+pub const HAVE_TIMES: u32 = 1;
+pub const HAVE_TOWLOWER: u32 = 1;
+pub const HAVE_TOWUPPER: u32 = 1;
+pub const HAVE_TTYNAME: u32 = 1;
+pub const HAVE_TZSET: u32 = 1;
+pub const HAVE_ULIMIT: u32 = 1;
+pub const HAVE_UNAME: u32 = 1;
+pub const HAVE_UNSETENV: u32 = 1;
+pub const HAVE_VASPRINTF: u32 = 1;
+pub const HAVE_VPRINTF: u32 = 1;
+pub const HAVE_VSNPRINTF: u32 = 1;
+pub const HAVE_WAITPID: u32 = 1;
+pub const HAVE_WAIT3: u32 = 1;
+pub const HAVE_WCRTOMB: u32 = 1;
+pub const HAVE_WCSCOLL: u32 = 1;
+pub const HAVE_WCSDUP: u32 = 1;
+pub const HAVE_WCTYPE: u32 = 1;
+pub const HAVE_WCSWIDTH: u32 = 1;
+pub const HAVE_WCWIDTH: u32 = 1;
+pub const HAVE_ARPA_INET_H: u32 = 1;
+pub const HAVE_DIRENT_H: u32 = 1;
+pub const HAVE_DLFCN_H: u32 = 1;
+pub const HAVE_GRP_H: u32 = 1;
+pub const HAVE_INTTYPES_H: u32 = 1;
+pub const HAVE_LANGINFO_H: u32 = 1;
+pub const HAVE_LIMITS_H: u32 = 1;
+pub const HAVE_LOCALE_H: u32 = 1;
+pub const HAVE_NETDB_H: u32 = 1;
+pub const HAVE_NETINET_IN_H: u32 = 1;
+pub const HAVE_PWD_H: u32 = 1;
+pub const HAVE_REGEX_H: u32 = 1;
+pub const HAVE_STDLIB_H: u32 = 1;
+pub const HAVE_STDARG_H: u32 = 1;
+pub const HAVE_STRING_H: u32 = 1;
+pub const HAVE_STRINGS_H: u32 = 1;
+pub const HAVE_MEMORY_H: u32 = 1;
+pub const HAVE_STDBOOL_H: u32 = 1;
+pub const HAVE_STDDEF_H: u32 = 1;
+pub const HAVE_STDINT_H: u32 = 1;
+pub const HAVE_SYSLOG_H: u32 = 1;
+pub const HAVE_SYS_FILE_H: u32 = 1;
+pub const HAVE_SYS_IOCTL_H: u32 = 1;
+pub const HAVE_SYS_MMAN_H: u32 = 1;
+pub const HAVE_SYS_PARAM_H: u32 = 1;
+pub const HAVE_SYS_RANDOM_H: u32 = 1;
+pub const HAVE_SYS_RESOURCE_H: u32 = 1;
+pub const HAVE_SYS_SELECT_H: u32 = 1;
+pub const HAVE_SYS_SOCKET_H: u32 = 1;
+pub const HAVE_SYS_STAT_H: u32 = 1;
+pub const HAVE_SYS_TIME_H: u32 = 1;
+pub const TIME_WITH_SYS_TIME: u32 = 1;
+pub const HAVE_SYS_TIMES_H: u32 = 1;
+pub const HAVE_SYS_TYPES_H: u32 = 1;
+pub const HAVE_SYS_WAIT_H: u32 = 1;
+pub const HAVE_TERMCAP_H: u32 = 1;
+pub const HAVE_TERMIO_H: u32 = 1;
+pub const HAVE_TERMIOS_H: u32 = 1;
+pub const HAVE_ULIMIT_H: u32 = 1;
+pub const HAVE_UNISTD_H: u32 = 1;
+pub const HAVE_WCHAR_H: u32 = 1;
+pub const HAVE_WCTYPE_H: u32 = 1;
+pub const HAVE_LIBDL: u32 = 1;
+pub const HAVE_ARGZ_H: u32 = 1;
+pub const HAVE_ERRNO_H: u32 = 1;
+pub const HAVE_FCNTL_H: u32 = 1;
+pub const HAVE_MALLOC_H: u32 = 1;
+pub const HAVE_STDIO_EXT_H: u32 = 1;
+pub const HAVE_DCGETTEXT: u32 = 1;
+pub const HAVE_LOCALECONV: u32 = 1;
+pub const HAVE_MEMPCPY: u32 = 1;
+pub const HAVE_MMAP: u32 = 1;
+pub const HAVE_MREMAP: u32 = 1;
+pub const HAVE_MUNMAP: u32 = 1;
+pub const HAVE_STPCPY: u32 = 1;
+pub const HAVE_STRCSPN: u32 = 1;
+pub const HAVE_STRDUP: u32 = 1;
+pub const HAVE___ARGZ_COUNT: u32 = 1;
+pub const HAVE___ARGZ_NEXT: u32 = 1;
+pub const HAVE___ARGZ_STRINGIFY: u32 = 1;
+pub const RESTRICTED_SHELL_NAME: &'static [u8; 6usize] = b"rbash\0";
+pub const _WCHAR_H: u32 = 1;
+pub const _FEATURES_H: u32 = 1;
+pub const _ISOC95_SOURCE: u32 = 1;
+pub const _ISOC99_SOURCE: u32 = 1;
+pub const _ISOC11_SOURCE: u32 = 1;
+pub const _POSIX_SOURCE: u32 = 1;
+pub const _POSIX_C_SOURCE: u32 = 200809;
+pub const _XOPEN_SOURCE: u32 = 700;
+pub const _XOPEN_SOURCE_EXTENDED: u32 = 1;
+pub const _LARGEFILE64_SOURCE: u32 = 1;
+pub const _DEFAULT_SOURCE: u32 = 1;
+pub const _ATFILE_SOURCE: u32 = 1;
+pub const __USE_ISOC11: u32 = 1;
+pub const __USE_ISOC99: u32 = 1;
+pub const __USE_ISOC95: u32 = 1;
+pub const __USE_POSIX: u32 = 1;
+pub const __USE_POSIX2: u32 = 1;
+pub const __USE_POSIX199309: u32 = 1;
+pub const __USE_POSIX199506: u32 = 1;
+pub const __USE_XOPEN2K: u32 = 1;
+pub const __USE_XOPEN2K8: u32 = 1;
+pub const __USE_XOPEN: u32 = 1;
+pub const __USE_XOPEN_EXTENDED: u32 = 1;
+pub const __USE_UNIX98: u32 = 1;
+pub const _LARGEFILE_SOURCE: u32 = 1;
+pub const __USE_XOPEN2K8XSI: u32 = 1;
+pub const __USE_XOPEN2KXSI: u32 = 1;
+pub const __USE_LARGEFILE: u32 = 1;
+pub const __USE_LARGEFILE64: u32 = 1;
+pub const __USE_MISC: u32 = 1;
+pub const __USE_ATFILE: u32 = 1;
+pub const __USE_GNU: u32 = 1;
+pub const __USE_FORTIFY_LEVEL: u32 = 0;
+pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0;
+pub const _STDC_PREDEF_H: u32 = 1;
+pub const __STDC_IEC_559__: u32 = 1;
+pub const __STDC_IEC_559_COMPLEX__: u32 = 1;
+pub const __STDC_ISO_10646__: u32 = 201706;
+pub const __GNU_LIBRARY__: u32 = 6;
+pub const __GLIBC__: u32 = 2;
+pub const __GLIBC_MINOR__: u32 = 28;
+pub const _SYS_CDEFS_H: u32 = 1;
+pub const __glibc_c99_flexarr_available: u32 = 1;
+pub const __WORDSIZE: u32 = 64;
+pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1;
+pub const __SYSCALL_WORDSIZE: u32 = 64;
+pub const __HAVE_GENERIC_SELECTION: u32 = 1;
+pub const __GLIBC_USE_LIB_EXT2: u32 = 1;
+pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 1;
+pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 1;
+pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 1;
+pub const __HAVE_FLOAT128: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT128: u32 = 0;
+pub const __HAVE_FLOAT64X: u32 = 1;
+pub const __HAVE_FLOAT64X_LONG_DOUBLE: u32 = 1;
+pub const __HAVE_FLOAT16: u32 = 0;
+pub const __HAVE_FLOAT32: u32 = 1;
+pub const __HAVE_FLOAT64: u32 = 1;
+pub const __HAVE_FLOAT32X: u32 = 1;
+pub const __HAVE_FLOAT128X: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT16: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT32: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT64: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT32X: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT64X: u32 = 0;
+pub const __HAVE_DISTINCT_FLOAT128X: u32 = 0;
+pub const __HAVE_FLOATN_NOT_TYPEDEF: u32 = 0;
+pub const __GNUC_VA_LIST: u32 = 1;
+pub const _BITS_WCHAR_H: u32 = 1;
+pub const __wint_t_defined: u32 = 1;
+pub const _WINT_T: u32 = 1;
+pub const __mbstate_t_defined: u32 = 1;
+pub const ____mbstate_t_defined: u32 = 1;
+pub const ____FILE_defined: u32 = 1;
+pub const __FILE_defined: u32 = 1;
+pub const _BITS_TYPES_LOCALE_T_H: u32 = 1;
+pub const _BITS_TYPES___LOCALE_T_H: u32 = 1;
+pub const WEOF: u32 = 4294967295;
+pub const _WCTYPE_H: u32 = 1;
+pub const _BITS_TYPES_H: u32 = 1;
+pub const _BITS_TYPESIZES_H: u32 = 1;
+pub const __OFF_T_MATCHES_OFF64_T: u32 = 1;
+pub const __INO_T_MATCHES_INO64_T: u32 = 1;
+pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1;
+pub const __FD_SETSIZE: u32 = 1024;
+pub const _BITS_WCTYPE_WCHAR_H: u32 = 1;
+pub const _ENDIAN_H: u32 = 1;
+pub const __LITTLE_ENDIAN: u32 = 1234;
+pub const __BIG_ENDIAN: u32 = 4321;
+pub const __PDP_ENDIAN: u32 = 3412;
+pub const __BYTE_ORDER: u32 = 1234;
+pub const __FLOAT_WORD_ORDER: u32 = 1234;
+pub const LITTLE_ENDIAN: u32 = 1234;
+pub const BIG_ENDIAN: u32 = 4321;
+pub const PDP_ENDIAN: u32 = 3412;
+pub const BYTE_ORDER: u32 = 1234;
+pub const _BITS_BYTESWAP_H: u32 = 1;
+pub const _BITS_UINTN_IDENTITY_H: u32 = 1;
+pub const HANDLE_MULTIBYTE: u32 = 1;
+pub const _LIBC_LIMITS_H_: u32 = 1;
+pub const MB_LEN_MAX: u32 = 16;
+pub const CHAR_WIDTH: u32 = 8;
+pub const SCHAR_WIDTH: u32 = 8;
+pub const UCHAR_WIDTH: u32 = 8;
+pub const SHRT_WIDTH: u32 = 16;
+pub const USHRT_WIDTH: u32 = 16;
+pub const INT_WIDTH: u32 = 32;
+pub const UINT_WIDTH: u32 = 32;
+pub const LONG_WIDTH: u32 = 64;
+pub const ULONG_WIDTH: u32 = 64;
+pub const LLONG_WIDTH: u32 = 64;
+pub const ULLONG_WIDTH: u32 = 64;
+pub const _BITS_POSIX1_LIM_H: u32 = 1;
+pub const _POSIX_AIO_LISTIO_MAX: u32 = 2;
+pub const _POSIX_AIO_MAX: u32 = 1;
+pub const _POSIX_ARG_MAX: u32 = 4096;
+pub const _POSIX_CHILD_MAX: u32 = 25;
+pub const _POSIX_DELAYTIMER_MAX: u32 = 32;
+pub const _POSIX_HOST_NAME_MAX: u32 = 255;
+pub const _POSIX_LINK_MAX: u32 = 8;
+pub const _POSIX_LOGIN_NAME_MAX: u32 = 9;
+pub const _POSIX_MAX_CANON: u32 = 255;
+pub const _POSIX_MAX_INPUT: u32 = 255;
+pub const _POSIX_MQ_OPEN_MAX: u32 = 8;
+pub const _POSIX_MQ_PRIO_MAX: u32 = 32;
+pub const _POSIX_NAME_MAX: u32 = 14;
+pub const _POSIX_NGROUPS_MAX: u32 = 8;
+pub const _POSIX_OPEN_MAX: u32 = 20;
+pub const _POSIX_FD_SETSIZE: u32 = 20;
+pub const _POSIX_PATH_MAX: u32 = 256;
+pub const _POSIX_PIPE_BUF: u32 = 512;
+pub const _POSIX_RE_DUP_MAX: u32 = 255;
+pub const _POSIX_RTSIG_MAX: u32 = 8;
+pub const _POSIX_SEM_NSEMS_MAX: u32 = 256;
+pub const _POSIX_SEM_VALUE_MAX: u32 = 32767;
+pub const _POSIX_SIGQUEUE_MAX: u32 = 32;
+pub const _POSIX_SSIZE_MAX: u32 = 32767;
+pub const _POSIX_STREAM_MAX: u32 = 8;
+pub const _POSIX_SYMLINK_MAX: u32 = 255;
+pub const _POSIX_SYMLOOP_MAX: u32 = 8;
+pub const _POSIX_TIMER_MAX: u32 = 32;
+pub const _POSIX_TTY_NAME_MAX: u32 = 9;
+pub const _POSIX_TZNAME_MAX: u32 = 6;
+pub const _POSIX_QLIMIT: u32 = 1;
+pub const _POSIX_HIWAT: u32 = 512;
+pub const _POSIX_UIO_MAXIOV: u32 = 16;
+pub const _POSIX_CLOCKRES_MIN: u32 = 20000000;
+pub const NR_OPEN: u32 = 1024;
+pub const NGROUPS_MAX: u32 = 65536;
+pub const ARG_MAX: u32 = 131072;
+pub const LINK_MAX: u32 = 127;
+pub const MAX_CANON: u32 = 255;
+pub const MAX_INPUT: u32 = 255;
+pub const NAME_MAX: u32 = 255;
+pub const PATH_MAX: u32 = 4096;
+pub const PIPE_BUF: u32 = 4096;
+pub const XATTR_NAME_MAX: u32 = 255;
+pub const XATTR_SIZE_MAX: u32 = 65536;
+pub const XATTR_LIST_MAX: u32 = 65536;
+pub const RTSIG_MAX: u32 = 32;
+pub const _POSIX_THREAD_KEYS_MAX: u32 = 128;
+pub const PTHREAD_KEYS_MAX: u32 = 1024;
+pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: u32 = 4;
+pub const PTHREAD_DESTRUCTOR_ITERATIONS: u32 = 4;
+pub const _POSIX_THREAD_THREADS_MAX: u32 = 64;
+pub const AIO_PRIO_DELTA_MAX: u32 = 20;
+pub const PTHREAD_STACK_MIN: u32 = 16384;
+pub const DELAYTIMER_MAX: u32 = 2147483647;
+pub const TTY_NAME_MAX: u32 = 32;
+pub const LOGIN_NAME_MAX: u32 = 256;
+pub const HOST_NAME_MAX: u32 = 64;
+pub const MQ_PRIO_MAX: u32 = 32768;
+pub const SEM_VALUE_MAX: u32 = 2147483647;
+pub const _BITS_POSIX2_LIM_H: u32 = 1;
+pub const _POSIX2_BC_BASE_MAX: u32 = 99;
+pub const _POSIX2_BC_DIM_MAX: u32 = 2048;
+pub const _POSIX2_BC_SCALE_MAX: u32 = 99;
+pub const _POSIX2_BC_STRING_MAX: u32 = 1000;
+pub const _POSIX2_COLL_WEIGHTS_MAX: u32 = 2;
+pub const _POSIX2_EXPR_NEST_MAX: u32 = 32;
+pub const _POSIX2_LINE_MAX: u32 = 2048;
+pub const _POSIX2_RE_DUP_MAX: u32 = 255;
+pub const _POSIX2_CHARCLASS_NAME_MAX: u32 = 14;
+pub const BC_BASE_MAX: u32 = 99;
+pub const BC_DIM_MAX: u32 = 2048;
+pub const BC_SCALE_MAX: u32 = 99;
+pub const BC_STRING_MAX: u32 = 1000;
+pub const COLL_WEIGHTS_MAX: u32 = 255;
+pub const EXPR_NEST_MAX: u32 = 32;
+pub const LINE_MAX: u32 = 2048;
+pub const CHARCLASS_NAME_MAX: u32 = 2048;
+pub const RE_DUP_MAX: u32 = 32767;
+pub const _XOPEN_LIM_H: u32 = 1;
+pub const _XOPEN_IOV_MAX: u32 = 16;
+pub const _BITS_UIO_LIM_H: u32 = 1;
+pub const __IOV_MAX: u32 = 1024;
+pub const IOV_MAX: u32 = 1024;
+pub const NL_ARGMAX: u32 = 4096;
+pub const NL_LANGMAX: u32 = 2048;
+pub const NZERO: u32 = 20;
+pub const WORD_BIT: u32 = 32;
+pub const LONG_BIT: u32 = 64;
+pub const _UNISTD_H: u32 = 1;
+pub const _POSIX_VERSION: u32 = 200809;
+pub const __POSIX2_THIS_VERSION: u32 = 200809;
+pub const _POSIX2_VERSION: u32 = 200809;
+pub const _POSIX2_C_VERSION: u32 = 200809;
+pub const _POSIX2_C_BIND: u32 = 200809;
+pub const _POSIX2_C_DEV: u32 = 200809;
+pub const _POSIX2_SW_DEV: u32 = 200809;
+pub const _POSIX2_LOCALEDEF: u32 = 200809;
+pub const _XOPEN_VERSION: u32 = 700;
+pub const _XOPEN_XCU_VERSION: u32 = 4;
+pub const _XOPEN_XPG2: u32 = 1;
+pub const _XOPEN_XPG3: u32 = 1;
+pub const _XOPEN_XPG4: u32 = 1;
+pub const _XOPEN_UNIX: u32 = 1;
+pub const _XOPEN_ENH_I18N: u32 = 1;
+pub const _XOPEN_LEGACY: u32 = 1;
+pub const _BITS_POSIX_OPT_H: u32 = 1;
+pub const _POSIX_JOB_CONTROL: u32 = 1;
+pub const _POSIX_SAVED_IDS: u32 = 1;
+pub const _POSIX_PRIORITY_SCHEDULING: u32 = 200809;
+pub const _POSIX_SYNCHRONIZED_IO: u32 = 200809;
+pub const _POSIX_FSYNC: u32 = 200809;
+pub const _POSIX_MAPPED_FILES: u32 = 200809;
+pub const _POSIX_MEMLOCK: u32 = 200809;
+pub const _POSIX_MEMLOCK_RANGE: u32 = 200809;
+pub const _POSIX_MEMORY_PROTECTION: u32 = 200809;
+pub const _POSIX_CHOWN_RESTRICTED: u32 = 0;
+pub const _POSIX_VDISABLE: u8 = 0u8;
+pub const _POSIX_NO_TRUNC: u32 = 1;
+pub const _XOPEN_REALTIME: u32 = 1;
+pub const _XOPEN_REALTIME_THREADS: u32 = 1;
+pub const _XOPEN_SHM: u32 = 1;
+pub const _POSIX_THREADS: u32 = 200809;
+pub const _POSIX_REENTRANT_FUNCTIONS: u32 = 1;
+pub const _POSIX_THREAD_SAFE_FUNCTIONS: u32 = 200809;
+pub const _POSIX_THREAD_PRIORITY_SCHEDULING: u32 = 200809;
+pub const _POSIX_THREAD_ATTR_STACKSIZE: u32 = 200809;
+pub const _POSIX_THREAD_ATTR_STACKADDR: u32 = 200809;
+pub const _POSIX_THREAD_PRIO_INHERIT: u32 = 200809;
+pub const _POSIX_THREAD_PRIO_PROTECT: u32 = 200809;
+pub const _POSIX_THREAD_ROBUST_PRIO_INHERIT: u32 = 200809;
+pub const _POSIX_THREAD_ROBUST_PRIO_PROTECT: i32 = -1;
+pub const _POSIX_SEMAPHORES: u32 = 200809;
+pub const _POSIX_REALTIME_SIGNALS: u32 = 200809;
+pub const _POSIX_ASYNCHRONOUS_IO: u32 = 200809;
+pub const _POSIX_ASYNC_IO: u32 = 1;
+pub const _LFS_ASYNCHRONOUS_IO: u32 = 1;
+pub const _POSIX_PRIORITIZED_IO: u32 = 200809;
+pub const _LFS64_ASYNCHRONOUS_IO: u32 = 1;
+pub const _LFS_LARGEFILE: u32 = 1;
+pub const _LFS64_LARGEFILE: u32 = 1;
+pub const _LFS64_STDIO: u32 = 1;
+pub const _POSIX_SHARED_MEMORY_OBJECTS: u32 = 200809;
+pub const _POSIX_CPUTIME: u32 = 0;
+pub const _POSIX_THREAD_CPUTIME: u32 = 0;
+pub const _POSIX_REGEXP: u32 = 1;
+pub const _POSIX_READER_WRITER_LOCKS: u32 = 200809;
+pub const _POSIX_SHELL: u32 = 1;
+pub const _POSIX_TIMEOUTS: u32 = 200809;
+pub const _POSIX_SPIN_LOCKS: u32 = 200809;
+pub const _POSIX_SPAWN: u32 = 200809;
+pub const _POSIX_TIMERS: u32 = 200809;
+pub const _POSIX_BARRIERS: u32 = 200809;
+pub const _POSIX_MESSAGE_PASSING: u32 = 200809;
+pub const _POSIX_THREAD_PROCESS_SHARED: u32 = 200809;
+pub const _POSIX_MONOTONIC_CLOCK: u32 = 0;
+pub const _POSIX_CLOCK_SELECTION: u32 = 200809;
+pub const _POSIX_ADVISORY_INFO: u32 = 200809;
+pub const _POSIX_IPV6: u32 = 200809;
+pub const _POSIX_RAW_SOCKETS: u32 = 200809;
+pub const _POSIX2_CHAR_TERM: u32 = 200809;
+pub const _POSIX_SPORADIC_SERVER: i32 = -1;
+pub const _POSIX_THREAD_SPORADIC_SERVER: i32 = -1;
+pub const _POSIX_TRACE: i32 = -1;
+pub const _POSIX_TRACE_EVENT_FILTER: i32 = -1;
+pub const _POSIX_TRACE_INHERIT: i32 = -1;
+pub const _POSIX_TRACE_LOG: i32 = -1;
+pub const _POSIX_TYPED_MEMORY_OBJECTS: i32 = -1;
+pub const _POSIX_V7_LPBIG_OFFBIG: i32 = -1;
+pub const _POSIX_V6_LPBIG_OFFBIG: i32 = -1;
+pub const _XBS5_LPBIG_OFFBIG: i32 = -1;
+pub const _POSIX_V7_LP64_OFF64: u32 = 1;
+pub const _POSIX_V6_LP64_OFF64: u32 = 1;
+pub const _XBS5_LP64_OFF64: u32 = 1;
+pub const __ILP32_OFF32_CFLAGS: &'static [u8; 5usize] = b"-m32\0";
+pub const __ILP32_OFF32_LDFLAGS: &'static [u8; 5usize] = b"-m32\0";
+pub const __ILP32_OFFBIG_CFLAGS: &'static [u8; 48usize] =
+ b"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64\0";
+pub const __ILP32_OFFBIG_LDFLAGS: &'static [u8; 5usize] = b"-m32\0";
+pub const __LP64_OFF64_CFLAGS: &'static [u8; 5usize] = b"-m64\0";
+pub const __LP64_OFF64_LDFLAGS: &'static [u8; 5usize] = b"-m64\0";
+pub const STDIN_FILENO: u32 = 0;
+pub const STDOUT_FILENO: u32 = 1;
+pub const STDERR_FILENO: u32 = 2;
+pub const R_OK: u32 = 4;
+pub const W_OK: u32 = 2;
+pub const X_OK: u32 = 1;
+pub const F_OK: u32 = 0;
+pub const SEEK_SET: u32 = 0;
+pub const SEEK_CUR: u32 = 1;
+pub const SEEK_END: u32 = 2;
+pub const SEEK_DATA: u32 = 3;
+pub const SEEK_HOLE: u32 = 4;
+pub const L_SET: u32 = 0;
+pub const L_INCR: u32 = 1;
+pub const L_XTND: u32 = 2;
+pub const _GETOPT_POSIX_H: u32 = 1;
+pub const _GETOPT_CORE_H: u32 = 1;
+pub const F_ULOCK: u32 = 0;
+pub const F_LOCK: u32 = 1;
+pub const F_TLOCK: u32 = 2;
+pub const F_TEST: u32 = 3;
+pub const _BITS_SIGNUM_H: u32 = 1;
+pub const _BITS_SIGNUM_GENERIC_H: u32 = 1;
+pub const SIGINT: u32 = 2;
+pub const SIGILL: u32 = 4;
+pub const SIGABRT: u32 = 6;
+pub const SIGFPE: u32 = 8;
+pub const SIGSEGV: u32 = 11;
+pub const SIGTERM: u32 = 15;
+pub const SIGHUP: u32 = 1;
+pub const SIGQUIT: u32 = 3;
+pub const SIGTRAP: u32 = 5;
+pub const SIGKILL: u32 = 9;
+pub const SIGBUS: u32 = 10;
+pub const SIGSYS: u32 = 12;
+pub const SIGPIPE: u32 = 13;
+pub const SIGALRM: u32 = 14;
+pub const SIGURG: u32 = 16;
+pub const SIGSTOP: u32 = 17;
+pub const SIGTSTP: u32 = 18;
+pub const SIGCONT: u32 = 19;
+pub const SIGCHLD: u32 = 20;
+pub const SIGTTIN: u32 = 21;
+pub const SIGTTOU: u32 = 22;
+pub const SIGPOLL: u32 = 23;
+pub const SIGXCPU: u32 = 24;
+pub const SIGXFSZ: u32 = 25;
+pub const SIGVTALRM: u32 = 26;
+pub const SIGPROF: u32 = 27;
+pub const SIGUSR1: u32 = 30;
+pub const SIGUSR2: u32 = 31;
+pub const SIGWINCH: u32 = 28;
+pub const SIGIO: u32 = 23;
+pub const SIGIOT: u32 = 6;
+pub const SIGCLD: u32 = 20;
+pub const __SIGRTMIN: u32 = 32;
+pub const __SIGRTMAX: u32 = 32;
+pub const _NSIG: u32 = 33;
+pub const SIGSTKFLT: u32 = 16;
+pub const SIGPWR: u32 = 30;
+pub const __sig_atomic_t_defined: u32 = 1;
+pub const __sigset_t_defined: u32 = 1;
+pub const _STRUCT_TIMESPEC: u32 = 1;
+pub const __siginfo_t_defined: u32 = 1;
+pub const __SI_MAX_SIZE: u32 = 128;
+pub const _BITS_SIGINFO_ARCH_H: u32 = 1;
+pub const __SI_ERRNO_THEN_CODE: u32 = 1;
+pub const __SI_HAVE_SIGSYS: u32 = 1;
+pub const _BITS_SIGINFO_CONSTS_H: u32 = 1;
+pub const __SI_ASYNCIO_AFTER_SIGIO: u32 = 1;
+pub const _BITS_SIGINFO_CONSTS_ARCH_H: u32 = 1;
+pub const __sigevent_t_defined: u32 = 1;
+pub const __SIGEV_MAX_SIZE: u32 = 64;
+pub const __have_pthread_attr_t: u32 = 1;
+pub const _BITS_SIGEVENT_CONSTS_H: u32 = 1;
+pub const NSIG: u32 = 33;
+pub const _BITS_SIGACTION_H: u32 = 1;
+pub const SA_NOCLDSTOP: u32 = 1;
+pub const SA_NOCLDWAIT: u32 = 2;
+pub const SA_SIGINFO: u32 = 4;
+pub const SA_ONSTACK: u32 = 134217728;
+pub const SA_RESTART: u32 = 268435456;
+pub const SA_NODEFER: u32 = 1073741824;
+pub const SA_RESETHAND: u32 = 2147483648;
+pub const SA_INTERRUPT: u32 = 536870912;
+pub const SA_NOMASK: u32 = 1073741824;
+pub const SA_ONESHOT: u32 = 2147483648;
+pub const SA_STACK: u32 = 134217728;
+pub const SIG_BLOCK: u32 = 0;
+pub const SIG_UNBLOCK: u32 = 1;
+pub const SIG_SETMASK: u32 = 2;
+pub const _BITS_SIGCONTEXT_H: u32 = 1;
+pub const FP_XSTATE_MAGIC1: u32 = 1179670611;
+pub const FP_XSTATE_MAGIC2: u32 = 1179670597;
+pub const __stack_t_defined: u32 = 1;
+pub const _SYS_UCONTEXT_H: u32 = 1;
+pub const __NGREG: u32 = 23;
+pub const NGREG: u32 = 23;
+pub const _BITS_SIGSTACK_H: u32 = 1;
+pub const MINSIGSTKSZ: u32 = 2048;
+pub const SIGSTKSZ: u32 = 8192;
+pub const _BITS_SS_FLAGS_H: u32 = 1;
+pub const __sigstack_defined: u32 = 1;
+pub const _BITS_PTHREADTYPES_COMMON_H: u32 = 1;
+pub const _THREAD_SHARED_TYPES_H: u32 = 1;
+pub const _BITS_PTHREADTYPES_ARCH_H: u32 = 1;
+pub const __SIZEOF_PTHREAD_MUTEX_T: u32 = 40;
+pub const __SIZEOF_PTHREAD_ATTR_T: u32 = 56;
+pub const __SIZEOF_PTHREAD_RWLOCK_T: u32 = 56;
+pub const __SIZEOF_PTHREAD_BARRIER_T: u32 = 32;
+pub const __SIZEOF_PTHREAD_MUTEXATTR_T: u32 = 4;
+pub const __SIZEOF_PTHREAD_COND_T: u32 = 48;
+pub const __SIZEOF_PTHREAD_CONDATTR_T: u32 = 4;
+pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: u32 = 8;
+pub const __SIZEOF_PTHREAD_BARRIERATTR_T: u32 = 4;
+pub const __PTHREAD_MUTEX_LOCK_ELISION: u32 = 1;
+pub const __PTHREAD_MUTEX_NUSERS_AFTER_KIND: u32 = 0;
+pub const __PTHREAD_MUTEX_USE_UNION: u32 = 0;
+pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: u32 = 1;
+pub const __PTHREAD_MUTEX_HAVE_PREV: u32 = 1;
+pub const _BITS_SIGTHREAD_H: u32 = 1;
+pub const _STDINT_H: u32 = 1;
+pub const _BITS_STDINT_INTN_H: u32 = 1;
+pub const _BITS_STDINT_UINTN_H: u32 = 1;
+pub const INT8_MIN: i32 = -128;
+pub const INT16_MIN: i32 = -32768;
+pub const INT32_MIN: i32 = -2147483648;
+pub const INT8_MAX: u32 = 127;
+pub const INT16_MAX: u32 = 32767;
+pub const INT32_MAX: u32 = 2147483647;
+pub const UINT8_MAX: u32 = 255;
+pub const UINT16_MAX: u32 = 65535;
+pub const UINT32_MAX: u32 = 4294967295;
+pub const INT_LEAST8_MIN: i32 = -128;
+pub const INT_LEAST16_MIN: i32 = -32768;
+pub const INT_LEAST32_MIN: i32 = -2147483648;
+pub const INT_LEAST8_MAX: u32 = 127;
+pub const INT_LEAST16_MAX: u32 = 32767;
+pub const INT_LEAST32_MAX: u32 = 2147483647;
+pub const UINT_LEAST8_MAX: u32 = 255;
+pub const UINT_LEAST16_MAX: u32 = 65535;
+pub const UINT_LEAST32_MAX: u32 = 4294967295;
+pub const INT_FAST8_MIN: i32 = -128;
+pub const INT_FAST16_MIN: i64 = -9223372036854775808;
+pub const INT_FAST32_MIN: i64 = -9223372036854775808;
+pub const INT_FAST8_MAX: u32 = 127;
+pub const INT_FAST16_MAX: u64 = 9223372036854775807;
+pub const INT_FAST32_MAX: u64 = 9223372036854775807;
+pub const UINT_FAST8_MAX: u32 = 255;
+pub const UINT_FAST16_MAX: i32 = -1;
+pub const UINT_FAST32_MAX: i32 = -1;
+pub const INTPTR_MIN: i64 = -9223372036854775808;
+pub const INTPTR_MAX: u64 = 9223372036854775807;
+pub const UINTPTR_MAX: i32 = -1;
+pub const PTRDIFF_MIN: i64 = -9223372036854775808;
+pub const PTRDIFF_MAX: u64 = 9223372036854775807;
+pub const SIG_ATOMIC_MIN: i32 = -2147483648;
+pub const SIG_ATOMIC_MAX: u32 = 2147483647;
+pub const SIZE_MAX: i32 = -1;
+pub const WINT_MIN: u32 = 0;
+pub const WINT_MAX: u32 = 4294967295;
+pub const INT8_WIDTH: u32 = 8;
+pub const UINT8_WIDTH: u32 = 8;
+pub const INT16_WIDTH: u32 = 16;
+pub const UINT16_WIDTH: u32 = 16;
+pub const INT32_WIDTH: u32 = 32;
+pub const UINT32_WIDTH: u32 = 32;
+pub const INT64_WIDTH: u32 = 64;
+pub const UINT64_WIDTH: u32 = 64;
+pub const INT_LEAST8_WIDTH: u32 = 8;
+pub const UINT_LEAST8_WIDTH: u32 = 8;
+pub const INT_LEAST16_WIDTH: u32 = 16;
+pub const UINT_LEAST16_WIDTH: u32 = 16;
+pub const INT_LEAST32_WIDTH: u32 = 32;
+pub const UINT_LEAST32_WIDTH: u32 = 32;
+pub const INT_LEAST64_WIDTH: u32 = 64;
+pub const UINT_LEAST64_WIDTH: u32 = 64;
+pub const INT_FAST8_WIDTH: u32 = 8;
+pub const UINT_FAST8_WIDTH: u32 = 8;
+pub const INT_FAST16_WIDTH: u32 = 64;
+pub const UINT_FAST16_WIDTH: u32 = 64;
+pub const INT_FAST32_WIDTH: u32 = 64;
+pub const UINT_FAST32_WIDTH: u32 = 64;
+pub const INT_FAST64_WIDTH: u32 = 64;
+pub const UINT_FAST64_WIDTH: u32 = 64;
+pub const INTPTR_WIDTH: u32 = 64;
+pub const UINTPTR_WIDTH: u32 = 64;
+pub const INTMAX_WIDTH: u32 = 64;
+pub const UINTMAX_WIDTH: u32 = 64;
+pub const PTRDIFF_WIDTH: u32 = 64;
+pub const SIG_ATOMIC_WIDTH: u32 = 32;
+pub const SIZE_WIDTH: u32 = 64;
+pub const WCHAR_WIDTH: u32 = 32;
+pub const WINT_WIDTH: u32 = 32;
+pub const REDIR_VARASSIGN: u32 = 1;
+pub const AMBIGUOUS_REDIRECT: i32 = -1;
+pub const NOCLOBBER_REDIRECT: i32 = -2;
+pub const RESTRICTED_REDIRECT: i32 = -3;
+pub const HEREDOC_REDIRECT: i32 = -4;
+pub const BADVAR_REDIRECT: i32 = -5;
+pub const W_HASDOLLAR: u32 = 1;
+pub const W_QUOTED: u32 = 2;
+pub const W_ASSIGNMENT: u32 = 4;
+pub const W_SPLITSPACE: u32 = 8;
+pub const W_NOSPLIT: u32 = 16;
+pub const W_NOGLOB: u32 = 32;
+pub const W_NOSPLIT2: u32 = 64;
+pub const W_TILDEEXP: u32 = 128;
+pub const W_DOLLARAT: u32 = 256;
+pub const W_DOLLARSTAR: u32 = 512;
+pub const W_NOCOMSUB: u32 = 1024;
+pub const W_ASSIGNRHS: u32 = 2048;
+pub const W_NOTILDE: u32 = 4096;
+pub const W_ITILDE: u32 = 8192;
+pub const W_EXPANDRHS: u32 = 16384;
+pub const W_COMPASSIGN: u32 = 32768;
+pub const W_ASSNBLTIN: u32 = 65536;
+pub const W_ASSIGNARG: u32 = 131072;
+pub const W_HASQUOTEDNULL: u32 = 262144;
+pub const W_DQUOTE: u32 = 524288;
+pub const W_NOPROCSUB: u32 = 1048576;
+pub const W_SAWQUOTEDNULL: u32 = 2097152;
+pub const W_ASSIGNASSOC: u32 = 4194304;
+pub const W_ASSIGNARRAY: u32 = 8388608;
+pub const W_ARRAYIND: u32 = 16777216;
+pub const W_ASSNGLOBAL: u32 = 33554432;
+pub const W_NOBRACE: u32 = 67108864;
+pub const PF_EXPANDRHS: u32 = 32;
+pub const PF_ALLINDS: u32 = 64;
+pub const SUBSHELL_ASYNC: u32 = 1;
+pub const SUBSHELL_PAREN: u32 = 2;
+pub const SUBSHELL_COMSUB: u32 = 4;
+pub const SUBSHELL_FORK: u32 = 8;
+pub const SUBSHELL_PIPE: u32 = 16;
+pub const SUBSHELL_PROCSUB: u32 = 32;
+pub const SUBSHELL_COPROC: u32 = 64;
+pub const SUBSHELL_RESETTRAP: u32 = 128;
+pub const CMD_WANT_SUBSHELL: u32 = 1;
+pub const CMD_FORCE_SUBSHELL: u32 = 2;
+pub const CMD_INVERT_RETURN: u32 = 4;
+pub const CMD_IGNORE_RETURN: u32 = 8;
+pub const CMD_NO_FUNCTIONS: u32 = 16;
+pub const CMD_INHIBIT_EXPANSION: u32 = 32;
+pub const CMD_NO_FORK: u32 = 64;
+pub const CMD_TIME_PIPELINE: u32 = 128;
+pub const CMD_TIME_POSIX: u32 = 256;
+pub const CMD_AMPERSAND: u32 = 512;
+pub const CMD_STDIN_REDIR: u32 = 1024;
+pub const CMD_COMMAND_BUILTIN: u32 = 2048;
+pub const CMD_COPROC_SUBSHELL: u32 = 4096;
+pub const CMD_LASTPIPE: u32 = 8192;
+pub const CMD_STDPATH: u32 = 16384;
+pub const CMD_TRY_OPTIMIZING: u32 = 32768;
+pub const PRId8: &'static [u8; 2usize] = b"d\0";
+pub const PRId16: &'static [u8; 2usize] = b"d\0";
+pub const PRId32: &'static [u8; 2usize] = b"d\0";
+pub const PRId64: &'static [u8; 3usize] = b"ld\0";
+pub const PRIdLEAST8: &'static [u8; 2usize] = b"d\0";
+pub const PRIdLEAST16: &'static [u8; 2usize] = b"d\0";
+pub const PRIdLEAST32: &'static [u8; 2usize] = b"d\0";
+pub const PRIdLEAST64: &'static [u8; 3usize] = b"ld\0";
+pub const PRIdFAST8: &'static [u8; 2usize] = b"d\0";
+pub const PRIdFAST16: &'static [u8; 3usize] = b"ld\0";
+pub const PRIdFAST32: &'static [u8; 3usize] = b"ld\0";
+pub const PRIdFAST64: &'static [u8; 3usize] = b"ld\0";
+pub const PRIi8: &'static [u8; 2usize] = b"i\0";
+pub const PRIi16: &'static [u8; 2usize] = b"i\0";
+pub const PRIi32: &'static [u8; 2usize] = b"i\0";
+pub const PRIi64: &'static [u8; 3usize] = b"li\0";
+pub const PRIiLEAST8: &'static [u8; 2usize] = b"i\0";
+pub const PRIiLEAST16: &'static [u8; 2usize] = b"i\0";
+pub const PRIiLEAST32: &'static [u8; 2usize] = b"i\0";
+pub const PRIiLEAST64: &'static [u8; 3usize] = b"li\0";
+pub const PRIiFAST8: &'static [u8; 2usize] = b"i\0";
+pub const PRIiFAST16: &'static [u8; 3usize] = b"li\0";
+pub const PRIiFAST32: &'static [u8; 3usize] = b"li\0";
+pub const PRIiFAST64: &'static [u8; 3usize] = b"li\0";
+pub const PRIo8: &'static [u8; 2usize] = b"o\0";
+pub const PRIo16: &'static [u8; 2usize] = b"o\0";
+pub const PRIo32: &'static [u8; 2usize] = b"o\0";
+pub const PRIo64: &'static [u8; 3usize] = b"lo\0";
+pub const PRIoLEAST8: &'static [u8; 2usize] = b"o\0";
+pub const PRIoLEAST16: &'static [u8; 2usize] = b"o\0";
+pub const PRIoLEAST32: &'static [u8; 2usize] = b"o\0";
+pub const PRIoLEAST64: &'static [u8; 3usize] = b"lo\0";
+pub const PRIoFAST8: &'static [u8; 2usize] = b"o\0";
+pub const PRIoFAST16: &'static [u8; 3usize] = b"lo\0";
+pub const PRIoFAST32: &'static [u8; 3usize] = b"lo\0";
+pub const PRIoFAST64: &'static [u8; 3usize] = b"lo\0";
+pub const PRIXFAST8: &'static [u8; 2usize] = b"X\0";
+pub const PRIXFAST16: &'static [u8; 3usize] = b"lX\0";
+pub const PRIXFAST32: &'static [u8; 3usize] = b"lX\0";
+pub const PRIXFAST64: &'static [u8; 3usize] = b"lX\0";
+pub const PRIdMAX: &'static [u8; 3usize] = b"ld\0";
+pub const PRIiMAX: &'static [u8; 3usize] = b"li\0";
+pub const PRIoMAX: &'static [u8; 3usize] = b"lo\0";
+pub const PRIuMAX: &'static [u8; 3usize] = b"lu\0";
+pub const PRIxMAX: &'static [u8; 3usize] = b"lx\0";
+pub const PRIXMAX: &'static [u8; 3usize] = b"lX\0";
+pub const PRIdPTR: &'static [u8; 3usize] = b"ld\0";
+pub const PRIiPTR: &'static [u8; 3usize] = b"li\0";
+pub const PRIoPTR: &'static [u8; 3usize] = b"lo\0";
+pub const PRIuPTR: &'static [u8; 3usize] = b"lu\0";
+pub const PRIxPTR: &'static [u8; 3usize] = b"lx\0";
+pub const PRIXPTR: &'static [u8; 3usize] = b"lX\0";
+pub const SCNd8: &'static [u8; 4usize] = b"hhd\0";
+pub const SCNd16: &'static [u8; 3usize] = b"hd\0";
+pub const SCNd32: &'static [u8; 2usize] = b"d\0";
+pub const SCNd64: &'static [u8; 3usize] = b"ld\0";
+pub const SCNdLEAST8: &'static [u8; 4usize] = b"hhd\0";
+pub const SCNdLEAST16: &'static [u8; 3usize] = b"hd\0";
+pub const SCNdLEAST32: &'static [u8; 2usize] = b"d\0";
+pub const SCNdLEAST64: &'static [u8; 3usize] = b"ld\0";
+pub const SCNuLEAST8: &'static [u8; 4usize] = b"hhu\0";
+pub const SCNuLEAST16: &'static [u8; 3usize] = b"hu\0";
+pub const SCNuLEAST32: &'static [u8; 2usize] = b"u\0";
+pub const SCNuLEAST64: &'static [u8; 3usize] = b"lu\0";
+pub const SCNuFAST8: &'static [u8; 4usize] = b"hhu\0";
+pub const SCNuFAST16: &'static [u8; 3usize] = b"lu\0";
+pub const SCNuFAST32: &'static [u8; 3usize] = b"lu\0";
+pub const SCNuFAST64: &'static [u8; 3usize] = b"lu\0";
+pub const SCNo8: &'static [u8; 4usize] = b"hho\0";
+pub const SCNo16: &'static [u8; 3usize] = b"ho\0";
+pub const SCNo32: &'static [u8; 2usize] = b"o\0";
+pub const SCNo64: &'static [u8; 3usize] = b"lo\0";
+pub const SCNx8: &'static [u8; 4usize] = b"hhx\0";
+pub const SCNx16: &'static [u8; 3usize] = b"hx\0";
+pub const SCNx32: &'static [u8; 2usize] = b"x\0";
+pub const SCNx64: &'static [u8; 3usize] = b"lx\0";
+pub const SCNdMAX: &'static [u8; 3usize] = b"ld\0";
+pub const SCNiMAX: &'static [u8; 3usize] = b"li\0";
+pub const SCNoMAX: &'static [u8; 3usize] = b"lo\0";
+pub const SCNuMAX: &'static [u8; 3usize] = b"lu\0";
+pub const SCNxMAX: &'static [u8; 3usize] = b"lx\0";
+pub const SCNdPTR: &'static [u8; 3usize] = b"ld\0";
+pub const SCNiPTR: &'static [u8; 3usize] = b"li\0";
+pub const SCNoPTR: &'static [u8; 3usize] = b"lo\0";
+pub const SCNuPTR: &'static [u8; 3usize] = b"lu\0";
+pub const SCNxPTR: &'static [u8; 3usize] = b"lx\0";
+pub const GX_MARKDIRS: u32 = 1;
+pub const GX_NOCASE: u32 = 2;
+pub const GX_MATCHDOT: u32 = 4;
+pub const GX_MATCHDIRS: u32 = 8;
+pub const GX_ALLDIRS: u32 = 16;
+pub const GX_NULLDIR: u32 = 256;
+pub const GX_ADDCURDIR: u32 = 512;
+pub const GX_GLOBSTAR: u32 = 1024;
+pub const GX_RECURSE: u32 = 2048;
+pub const GX_SYMLINK: u32 = 4096;
+pub const INVALID: i32 = -1;
+pub const _STRMATCH_H: u32 = 1;
+pub const FNM_PATHNAME: u32 = 1;
+pub const FNM_NOESCAPE: u32 = 2;
+pub const FNM_PERIOD: u32 = 4;
+pub const FNM_LEADING_DIR: u32 = 8;
+pub const FNM_CASEFOLD: u32 = 16;
+pub const FNM_EXTMATCH: u32 = 32;
+pub const FNM_FIRSTCHAR: u32 = 64;
+pub const FNM_NOMATCH: u32 = 1;
+pub type _Float32 = f32;
+pub type _Float64 = f64;
+pub type _Float32x = f64;
+pub type _Float64x = f64;
+pub type wchar_t = ::std::os::raw::c_int;
+pub type va_list = __builtin_va_list;
+pub type __gnuc_va_list = __builtin_va_list;
+pub type wint_t = ::std::os::raw::c_uint;
+fn histtime(hlist: *mut HIST_ENTRY, histtimefmt: *const c_char) -> *mut c_char
+{
+unsafe {
+ static mut timestr: [c_char;128] = [0;128];
+
+ let t = history_get_time(hlist);
+ let tm = if t != 0 {libc::localtime(&t)} else {PT_NULL as *mut libc::tm};
+ if t != 0 && !tm.is_null() {
+ strftime(std::mem::transmute(×tr),
+ std::mem::size_of_val(×tr),
+ histtimefmt,
+ tm);
+ } else if !(*hlist).timestamp.is_null() && (*(*hlist).timestamp) != 0 {
+ let c_str = CString::new("%s: invalid timestamp").unwrap();
+ libc::snprintf(std::mem::transmute(×tr),
+ std::mem::size_of_val(×tr), c_str.as_ptr(),
+ if *((*hlist).timestamp) == b'#' as c_char {((*hlist).timestamp as usize + 1) as *mut c_char} else {(*hlist).timestamp});
+ } else {
+ libc::strcpy(std::mem::transmute(×tr), b"??\0".as_ptr() as *const c_char);
+ }
+
+ return timestr.as_mut_ptr();
+}
+pub type mbstate_t = __mbstate_t;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct _IO_FILE {
+ _unused: [u8; 0],
+}
+pub type __FILE = _IO_FILE;
+pub type FILE = _IO_FILE;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __locale_struct {
+ pub __locales: [*mut __locale_data; 13usize],
+ pub __ctype_b: *const ::std::os::raw::c_ushort,
+ pub __ctype_tolower: *const ::std::os::raw::c_int,
+ pub __ctype_toupper: *const ::std::os::raw::c_int,
+ pub __names: [*const ::std::os::raw::c_char; 13usize],
+}
+pub type __locale_t = *mut __locale_struct;
+pub type locale_t = __locale_t;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct tm {
+ _unused: [u8; 0],
+}
+extern "C" {
+ pub fn wcscpy(__dest: *mut wchar_t, __src: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcsncpy(__dest: *mut wchar_t, __src: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcscat(__dest: *mut wchar_t, __src: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcsncat(__dest: *mut wchar_t, __src: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcscmp(__s1: *const wchar_t, __s2: *const wchar_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsncmp(__s1: *const wchar_t, __s2: *const wchar_t, __n: usize)
+ -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcscasecmp(__s1: *const wchar_t, __s2: *const wchar_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsncasecmp(
+ __s1: *const wchar_t,
+ __s2: *const wchar_t,
+ __n: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcscasecmp_l(
+ __s1: *const wchar_t,
+ __s2: *const wchar_t,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsncasecmp_l(
+ __s1: *const wchar_t,
+ __s2: *const wchar_t,
+ __n: usize,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcscoll(__s1: *const wchar_t, __s2: *const wchar_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsxfrm(__s1: *mut wchar_t, __s2: *const wchar_t, __n: usize) -> usize;
+}
+extern "C" {
+ pub fn wcscoll_l(
+ __s1: *const wchar_t,
+ __s2: *const wchar_t,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsxfrm_l(
+ __s1: *mut wchar_t,
+ __s2: *const wchar_t,
+ __n: usize,
+ __loc: locale_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcsdup(__s: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcschr(__wcs: *const wchar_t, __wc: wchar_t) -> *mut ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsrchr(__wcs: *const wchar_t, __wc: wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcschrnul(__s: *const wchar_t, __wc: wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcscspn(__wcs: *const wchar_t, __reject: *const wchar_t) -> usize;
+}
+extern "C" {
+ pub fn wcsspn(__wcs: *const wchar_t, __accept: *const wchar_t) -> usize;
+}
+extern "C" {
+ pub fn wcspbrk(__wcs: *const wchar_t, __accept: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcsstr(__haystack: *const wchar_t, __needle: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcstok(
+ __s: *mut wchar_t,
+ __delim: *const wchar_t,
+ __ptr: *mut *mut wchar_t,
+ ) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcslen(__s: *const wchar_t) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn wcswcs(__haystack: *const wchar_t, __needle: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcsnlen(__s: *const wchar_t, __maxlen: usize) -> usize;
+}
+extern "C" {
+ pub fn wmemchr(__s: *const wchar_t, __c: wchar_t, __n: usize) -> *mut ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wmemcmp(__s1: *const wchar_t, __s2: *const wchar_t, __n: usize)
+ -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wmemcpy(__s1: *mut wchar_t, __s2: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wmemmove(__s1: *mut wchar_t, __s2: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wmemset(__s: *mut wchar_t, __c: wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wmempcpy(__s1: *mut wchar_t, __s2: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn btowc(__c: ::std::os::raw::c_int) -> wint_t;
+}
+extern "C" {
+ pub fn wctob(__c: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn mbsinit(__ps: *const mbstate_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn mbrtowc(
+ __pwc: *mut wchar_t,
+ __s: *const ::std::os::raw::c_char,
+ __n: usize,
+ __p: *mut mbstate_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcrtomb(__s: *mut ::std::os::raw::c_char, __wc: wchar_t, __ps: *mut mbstate_t) -> usize;
+}
+extern "C" {
+ pub fn __mbrlen(__s: *const ::std::os::raw::c_char, __n: usize, __ps: *mut mbstate_t) -> usize;
+}
+extern "C" {
+ pub fn mbrlen(__s: *const ::std::os::raw::c_char, __n: usize, __ps: *mut mbstate_t) -> usize;
+}
+extern "C" {
+ pub fn mbsrtowcs(
+ __dst: *mut wchar_t,
+ __src: *mut *const ::std::os::raw::c_char,
+ __len: usize,
+ __ps: *mut mbstate_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcsrtombs(
+ __dst: *mut ::std::os::raw::c_char,
+ __src: *mut *const wchar_t,
+ __len: usize,
+ __ps: *mut mbstate_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn mbsnrtowcs(
+ __dst: *mut wchar_t,
+ __src: *mut *const ::std::os::raw::c_char,
+ __nmc: usize,
+ __len: usize,
+ __ps: *mut mbstate_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcsnrtombs(
+ __dst: *mut ::std::os::raw::c_char,
+ __src: *mut *const wchar_t,
+ __nwc: usize,
+ __len: usize,
+ __ps: *mut mbstate_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcwidth(__c: wchar_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcswidth(__s: *const wchar_t, __n: usize) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcstod(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> f64;
+}
+extern "C" {
+ pub fn wcstof(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> f32;
+}
+extern "C" {
+ pub fn wcstold(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> f64;
+}
+extern "C" {
+ pub fn wcstof32(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> _Float32;
+}
+extern "C" {
+ pub fn wcstof64(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> _Float64;
+}
+extern "C" {
+ pub fn wcstof32x(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> _Float32x;
+}
+extern "C" {
+ pub fn wcstof64x(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t) -> _Float64x;
+}
+extern "C" {
+ pub fn wcstol(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn wcstoul(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn wcstoll(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_longlong;
+}
+extern "C" {
+ pub fn wcstoull(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_ulonglong;
+}
+extern "C" {
+ pub fn wcstoq(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_longlong;
+}
+extern "C" {
+ pub fn wcstouq(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_ulonglong;
+}
+extern "C" {
+ pub fn wcstol_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn wcstoul_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn wcstoll_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_longlong;
+}
+extern "C" {
+ pub fn wcstoull_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __base: ::std::os::raw::c_int,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_ulonglong;
+}
+extern "C" {
+ pub fn wcstod_l(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t, __loc: locale_t) -> f64;
+}
+extern "C" {
+ pub fn wcstof_l(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t, __loc: locale_t) -> f32;
+}
+extern "C" {
+ pub fn wcstold_l(__nptr: *const wchar_t, __endptr: *mut *mut wchar_t, __loc: locale_t) -> f64;
+}
+extern "C" {
+ pub fn wcstof32_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __loc: locale_t,
+ ) -> _Float32;
+}
+extern "C" {
+ pub fn wcstof64_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __loc: locale_t,
+ ) -> _Float64;
+}
+extern "C" {
+ pub fn wcstof32x_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __loc: locale_t,
+ ) -> _Float32x;
+}
+extern "C" {
+ pub fn wcstof64x_l(
+ __nptr: *const wchar_t,
+ __endptr: *mut *mut wchar_t,
+ __loc: locale_t,
+ ) -> _Float64x;
+}
+extern "C" {
+ pub fn wcpcpy(__dest: *mut wchar_t, __src: *const wchar_t) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn wcpncpy(__dest: *mut wchar_t, __src: *const wchar_t, __n: usize) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn open_wmemstream(__bufloc: *mut *mut wchar_t, __sizeloc: *mut usize) -> *mut __FILE;
+}
+extern "C" {
+ pub fn fwide(__fp: *mut __FILE, __mode: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fwprintf(__stream: *mut __FILE, __format: *const wchar_t, ...) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wprintf(__format: *const wchar_t, ...) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn swprintf(
+ __s: *mut wchar_t,
+ __n: usize,
+ __format: *const wchar_t,
+ ...
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vfwprintf(
+ __s: *mut __FILE,
+ __format: *const wchar_t,
+ __arg: *mut __va_list_tag,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vwprintf(__format: *const wchar_t, __arg: *mut __va_list_tag) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vswprintf(
+ __s: *mut wchar_t,
+ __n: usize,
+ __format: *const wchar_t,
+ __arg: *mut __va_list_tag,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fwscanf(__stream: *mut __FILE, __format: *const wchar_t, ...) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wscanf(__format: *const wchar_t, ...) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn swscanf(__s: *const wchar_t, __format: *const wchar_t, ...) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vfwscanf(
+ __s: *mut __FILE,
+ __format: *const wchar_t,
+ __arg: *mut __va_list_tag,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vwscanf(__format: *const wchar_t, __arg: *mut __va_list_tag) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn vswscanf(
+ __s: *const wchar_t,
+ __format: *const wchar_t,
+ __arg: *mut __va_list_tag,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fgetwc(__stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn getwc(__stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn getwchar() -> wint_t;
+}
+extern "C" {
+ pub fn fputwc(__wc: wchar_t, __stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn putwc(__wc: wchar_t, __stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn putwchar(__wc: wchar_t) -> wint_t;
+}
+extern "C" {
+ pub fn fgetws(
+ __ws: *mut wchar_t,
+ __n: ::std::os::raw::c_int,
+ __stream: *mut __FILE,
+ ) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn fputws(__ws: *const wchar_t, __stream: *mut __FILE) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn ungetwc(__wc: wint_t, __stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn getwc_unlocked(__stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn getwchar_unlocked() -> wint_t;
+}
+extern "C" {
+ pub fn fgetwc_unlocked(__stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn fputwc_unlocked(__wc: wchar_t, __stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn putwc_unlocked(__wc: wchar_t, __stream: *mut __FILE) -> wint_t;
+}
+extern "C" {
+ pub fn putwchar_unlocked(__wc: wchar_t) -> wint_t;
+}
+extern "C" {
+ pub fn fgetws_unlocked(
+ __ws: *mut wchar_t,
+ __n: ::std::os::raw::c_int,
+ __stream: *mut __FILE,
+ ) -> *mut wchar_t;
+}
+extern "C" {
+ pub fn fputws_unlocked(__ws: *const wchar_t, __stream: *mut __FILE) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsftime(
+ __s: *mut wchar_t,
+ __maxsize: usize,
+ __format: *const wchar_t,
+ __tp: *const tm,
+ ) -> usize;
+}
+extern "C" {
+ pub fn wcsftime_l(
+ __s: *mut wchar_t,
+ __maxsize: usize,
+ __format: *const wchar_t,
+ __tp: *const tm,
+ __loc: locale_t,
+ ) -> usize;
+}
+pub type __u_char = ::std::os::raw::c_uchar;
+pub type __u_short = ::std::os::raw::c_ushort;
+pub type __u_int = ::std::os::raw::c_uint;
+pub type __u_long = ::std::os::raw::c_ulong;
+pub type __int8_t = ::std::os::raw::c_schar;
+pub type __uint8_t = ::std::os::raw::c_uchar;
+pub type __int16_t = ::std::os::raw::c_short;
+pub type __uint16_t = ::std::os::raw::c_ushort;
+pub type __int32_t = ::std::os::raw::c_int;
+pub type __uint32_t = ::std::os::raw::c_uint;
+pub type __int64_t = ::std::os::raw::c_long;
+pub type __uint64_t = ::std::os::raw::c_ulong;
+pub type __int_least8_t = __int8_t;
+pub type __uint_least8_t = __uint8_t;
+pub type __int_least16_t = __int16_t;
+pub type __uint_least16_t = __uint16_t;
+pub type __int_least32_t = __int32_t;
+pub type __uint_least32_t = __uint32_t;
+pub type __int_least64_t = __int64_t;
+pub type __uint_least64_t = __uint64_t;
+pub type __quad_t = ::std::os::raw::c_long;
+pub type __u_quad_t = ::std::os::raw::c_ulong;
+pub type __intmax_t = ::std::os::raw::c_long;
+pub type __uintmax_t = ::std::os::raw::c_ulong;
+pub type __dev_t = ::std::os::raw::c_ulong;
+pub type __uid_t = ::std::os::raw::c_uint;
+pub type __gid_t = ::std::os::raw::c_uint;
+pub type __ino_t = ::std::os::raw::c_ulong;
+pub type __ino64_t = ::std::os::raw::c_ulong;
+pub type __mode_t = ::std::os::raw::c_uint;
+pub type __nlink_t = ::std::os::raw::c_ulong;
+pub type __off_t = ::std::os::raw::c_long;
+pub type __off64_t = ::std::os::raw::c_long;
+pub type __pid_t = ::std::os::raw::c_int;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __fsid_t {
+ pub __val: [::std::os::raw::c_int; 2usize],
+}
+pub type __clock_t = ::std::os::raw::c_long;
+pub type __rlim_t = ::std::os::raw::c_ulong;
+pub type __rlim64_t = ::std::os::raw::c_ulong;
+pub type __id_t = ::std::os::raw::c_uint;
+pub type __time_t = ::std::os::raw::c_long;
+pub type __useconds_t = ::std::os::raw::c_uint;
+pub type __suseconds_t = ::std::os::raw::c_long;
+pub type __daddr_t = ::std::os::raw::c_int;
+pub type __key_t = ::std::os::raw::c_int;
+pub type __clockid_t = ::std::os::raw::c_int;
+pub type __timer_t = *mut ::std::os::raw::c_void;
+pub type __blksize_t = ::std::os::raw::c_long;
+pub type __blkcnt_t = ::std::os::raw::c_long;
+pub type __blkcnt64_t = ::std::os::raw::c_long;
+pub type __fsblkcnt_t = ::std::os::raw::c_ulong;
+pub type __fsblkcnt64_t = ::std::os::raw::c_ulong;
+pub type __fsfilcnt_t = ::std::os::raw::c_ulong;
+pub type __fsfilcnt64_t = ::std::os::raw::c_ulong;
+pub type __fsword_t = ::std::os::raw::c_long;
+pub type __ssize_t = ::std::os::raw::c_long;
+pub type __syscall_slong_t = ::std::os::raw::c_long;
+pub type __syscall_ulong_t = ::std::os::raw::c_ulong;
+pub type __loff_t = __off64_t;
+pub type __caddr_t = *mut ::std::os::raw::c_char;
+pub type __intptr_t = ::std::os::raw::c_long;
+pub type __socklen_t = ::std::os::raw::c_uint;
+pub type __sig_atomic_t = ::std::os::raw::c_int;
+pub type wctype_t = ::std::os::raw::c_ulong;
+pub const __ISwupper: _bindgen_ty_1 = 0;
+pub const __ISwlower: _bindgen_ty_1 = 1;
+pub const __ISwalpha: _bindgen_ty_1 = 2;
+pub const __ISwdigit: _bindgen_ty_1 = 3;
+pub const __ISwxdigit: _bindgen_ty_1 = 4;
+pub const __ISwspace: _bindgen_ty_1 = 5;
+pub const __ISwprint: _bindgen_ty_1 = 6;
+pub const __ISwgraph: _bindgen_ty_1 = 7;
+pub const __ISwblank: _bindgen_ty_1 = 8;
+pub const __ISwcntrl: _bindgen_ty_1 = 9;
+pub const __ISwpunct: _bindgen_ty_1 = 10;
+pub const __ISwalnum: _bindgen_ty_1 = 11;
+pub const _ISwupper: _bindgen_ty_1 = 16777216;
+pub const _ISwlower: _bindgen_ty_1 = 33554432;
+pub const _ISwalpha: _bindgen_ty_1 = 67108864;
+pub const _ISwdigit: _bindgen_ty_1 = 134217728;
+pub const _ISwxdigit: _bindgen_ty_1 = 268435456;
+pub const _ISwspace: _bindgen_ty_1 = 536870912;
+pub const _ISwprint: _bindgen_ty_1 = 1073741824;
+pub const _ISwgraph: _bindgen_ty_1 = -2147483648;
+pub const _ISwblank: _bindgen_ty_1 = 65536;
+pub const _ISwcntrl: _bindgen_ty_1 = 131072;
+pub const _ISwpunct: _bindgen_ty_1 = 262144;
+pub const _ISwalnum: _bindgen_ty_1 = 524288;
+pub type _bindgen_ty_1 = i32;
+extern "C" {
+ pub fn iswalnum(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswalpha(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswcntrl(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswdigit(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswgraph(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswlower(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswprint(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswpunct(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswspace(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswupper(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswxdigit(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswblank(__wc: wint_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wctype(__property: *const ::std::os::raw::c_char) -> wctype_t;
+}
+extern "C" {
+ pub fn iswalnum_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswalpha_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswcntrl_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswdigit_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswgraph_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswlower_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswprint_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswpunct_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswspace_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswupper_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswxdigit_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iswblank_l(__wc: wint_t, __locale: locale_t) -> ::std::os::raw::c_int;
+}
+ pub fn wctrans_l(__property: *const ::std::os::raw::c_char, __locale: locale_t) -> wctrans_t;
+}
+extern "C" {
+ pub fn towctrans_l(__wc: wint_t, __desc: wctrans_t, __locale: locale_t) -> wint_t;
+}
+pub type gid_t = __gid_t;
+pub type uid_t = __uid_t;
+pub type off_t = __off_t;
+pub type off64_t = __off64_t;
+pub type useconds_t = __useconds_t;
+pub type pid_t = __pid_t;
+pub type socklen_t = __socklen_t;
+extern "C" {
+ pub fn access(
+ __name: *const ::std::os::raw::c_char,
+ __type: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn euidaccess(
+ __name: *const ::std::os::raw::c_char,
+ __type: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lseek(
+ __fd: ::std::os::raw::c_int,
+ __offset: __off_t,
+ __whence: ::std::os::raw::c_int,
+ ) -> __off_t;
+}
+extern "C" {
+ pub fn lseek64(
+ __fd: ::std::os::raw::c_int,
+ __offset: __off64_t,
+ __whence: ::std::os::raw::c_int,
+ ) -> __off64_t;
+}
+extern "C" {
+ pub fn close(__fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn read(
+ __fd: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_void,
+ __nbytes: usize,
+ ) -> isize;
+}
+extern "C" {
+ pub fn write(
+ __fd: ::std::os::raw::c_int,
+ __buf: *const ::std::os::raw::c_void,
+ __n: usize,
+ ) -> isize;
+}
+extern "C" {
+ pub fn pread(
+ __fd: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_void,
+ __nbytes: usize,
+ __offset: __off_t,
+ ) -> isize;
+}
+extern "C" {
+ pub fn pwrite(
+ __fd: ::std::os::raw::c_int,
+ __buf: *const ::std::os::raw::c_void,
+ __n: usize,
+ __offset: __off_t,
+ ) -> isize;
+}
+extern "C" {
+ pub fn pread64(
+ __fd: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_void,
+ __nbytes: usize,
+ __offset: __off64_t,
+ ) -> isize;
+}
+extern "C" {
+ pub fn pwrite64(
+ __fd: ::std::os::raw::c_int,
+ __buf: *const ::std::os::raw::c_void,
+ __n: usize,
+ __offset: __off64_t,
+ ) -> isize;
+}
+extern "C" {
+ pub fn alarm(__seconds: ::std::os::raw::c_uint) -> ::std::os::raw::c_uint;
+}
+extern "C" {
+ pub fn sleep(__seconds: ::std::os::raw::c_uint) -> ::std::os::raw::c_uint;
+}
+extern "C" {
+ pub fn ualarm(__value: __useconds_t, __interval: __useconds_t) -> __useconds_t;
+}
+extern "C" {
+ pub fn usleep(__useconds: __useconds_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn pause() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn chown(
+ __file: *const ::std::os::raw::c_char,
+ __owner: __uid_t,
+ __group: __gid_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fchown(
+ __fd: ::std::os::raw::c_int,
+ __owner: __uid_t,
+ __group: __gid_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lchown(
+ __file: *const ::std::os::raw::c_char,
+ __owner: __uid_t,
+ __group: __gid_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fchownat(
+ __fd: ::std::os::raw::c_int,
+ __file: *const ::std::os::raw::c_char,
+ __owner: __uid_t,
+ __group: __gid_t,
+ __flag: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn chdir(__path: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fchdir(__fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getcwd(__buf: *mut ::std::os::raw::c_char, __size: usize)
+ -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn dup3(
+ __fd: ::std::os::raw::c_int,
+ __fd2: ::std::os::raw::c_int,
+ __flags: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}__environ"]
+ pub static mut __environ: *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ #[link_name = "\u{1}environ"]
+ pub static mut environ: *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn execve(
+ __path: *const ::std::os::raw::c_char,
+ __argv: *const *mut ::std::os::raw::c_char,
+ __envp: *const *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fexecve(
+ __fd: ::std::os::raw::c_int,
+ __argv: *const *mut ::std::os::raw::c_char,
+ __envp: *const *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execv(
+ __path: *const ::std::os::raw::c_char,
+ __argv: *const *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execle(
+ __path: *const ::std::os::raw::c_char,
+ __arg: *const ::std::os::raw::c_char,
+ ...
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execl(
+ __path: *const ::std::os::raw::c_char,
+ __arg: *const ::std::os::raw::c_char,
+ ...
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execvp(
+ __file: *const ::std::os::raw::c_char,
+ __argv: *const *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execlp(
+ __file: *const ::std::os::raw::c_char,
+ __arg: *const ::std::os::raw::c_char,
+ ...
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn execvpe(
+ __file: *const ::std::os::raw::c_char,
+ __argv: *const *mut ::std::os::raw::c_char,
+ __envp: *const *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+pub const _PC_LINK_MAX: _bindgen_ty_2 = 0;
+pub const _PC_MAX_CANON: _bindgen_ty_2 = 1;
+pub const _PC_MAX_INPUT: _bindgen_ty_2 = 2;
+pub const _PC_NAME_MAX: _bindgen_ty_2 = 3;
+pub const _PC_PATH_MAX: _bindgen_ty_2 = 4;
+pub const _PC_PIPE_BUF: _bindgen_ty_2 = 5;
+pub const _PC_CHOWN_RESTRICTED: _bindgen_ty_2 = 6;
+pub const _PC_NO_TRUNC: _bindgen_ty_2 = 7;
+pub const _PC_VDISABLE: _bindgen_ty_2 = 8;
+pub const _PC_SYNC_IO: _bindgen_ty_2 = 9;
+pub const _PC_ASYNC_IO: _bindgen_ty_2 = 10;
+pub const _PC_PRIO_IO: _bindgen_ty_2 = 11;
+pub const _PC_SOCK_MAXBUF: _bindgen_ty_2 = 12;
+pub const _PC_FILESIZEBITS: _bindgen_ty_2 = 13;
+pub const _PC_REC_INCR_XFER_SIZE: _bindgen_ty_2 = 14;
+pub const _PC_REC_MAX_XFER_SIZE: _bindgen_ty_2 = 15;
+pub const _PC_REC_MIN_XFER_SIZE: _bindgen_ty_2 = 16;
+pub const _PC_REC_XFER_ALIGN: _bindgen_ty_2 = 17;
+pub const _PC_ALLOC_SIZE_MIN: _bindgen_ty_2 = 18;
+pub const _PC_SYMLINK_MAX: _bindgen_ty_2 = 19;
+pub const _PC_2_SYMLINKS: _bindgen_ty_2 = 20;
+pub type _bindgen_ty_2 = u32;
+pub const _SC_ARG_MAX: _bindgen_ty_3 = 0;
+pub const _SC_CHILD_MAX: _bindgen_ty_3 = 1;
+pub const _SC_CLK_TCK: _bindgen_ty_3 = 2;
+pub const _SC_NGROUPS_MAX: _bindgen_ty_3 = 3;
+pub const _SC_OPEN_MAX: _bindgen_ty_3 = 4;
+pub const _SC_STREAM_MAX: _bindgen_ty_3 = 5;
+pub const _SC_TZNAME_MAX: _bindgen_ty_3 = 6;
+pub const _SC_JOB_CONTROL: _bindgen_ty_3 = 7;
+pub const _SC_SAVED_IDS: _bindgen_ty_3 = 8;
+pub const _SC_REALTIME_SIGNALS: _bindgen_ty_3 = 9;
+pub const _SC_PRIORITY_SCHEDULING: _bindgen_ty_3 = 10;
+pub const _SC_TIMERS: _bindgen_ty_3 = 11;
+pub const _SC_ASYNCHRONOUS_IO: _bindgen_ty_3 = 12;
+pub const _SC_PRIORITIZED_IO: _bindgen_ty_3 = 13;
+pub const _SC_SYNCHRONIZED_IO: _bindgen_ty_3 = 14;
+pub const _SC_FSYNC: _bindgen_ty_3 = 15;
+pub const _SC_MAPPED_FILES: _bindgen_ty_3 = 16;
+pub const _SC_MEMLOCK: _bindgen_ty_3 = 17;
+pub const _SC_MEMLOCK_RANGE: _bindgen_ty_3 = 18;
+pub const _SC_MEMORY_PROTECTION: _bindgen_ty_3 = 19;
+pub const _SC_MESSAGE_PASSING: _bindgen_ty_3 = 20;
+pub const _SC_SEMAPHORES: _bindgen_ty_3 = 21;
+pub const _SC_SHARED_MEMORY_OBJECTS: _bindgen_ty_3 = 22;
+pub const _SC_AIO_LISTIO_MAX: _bindgen_ty_3 = 23;
+pub const _SC_AIO_MAX: _bindgen_ty_3 = 24;
+pub const _SC_AIO_PRIO_DELTA_MAX: _bindgen_ty_3 = 25;
+pub const _SC_DELAYTIMER_MAX: _bindgen_ty_3 = 26;
+pub const _SC_MQ_OPEN_MAX: _bindgen_ty_3 = 27;
+pub const _SC_MQ_PRIO_MAX: _bindgen_ty_3 = 28;
+pub const _SC_VERSION: _bindgen_ty_3 = 29;
+pub const _SC_PAGESIZE: _bindgen_ty_3 = 30;
+pub const _SC_RTSIG_MAX: _bindgen_ty_3 = 31;
+pub const _SC_SEM_NSEMS_MAX: _bindgen_ty_3 = 32;
+pub const _SC_SEM_VALUE_MAX: _bindgen_ty_3 = 33;
+pub const _SC_SIGQUEUE_MAX: _bindgen_ty_3 = 34;
+pub const _SC_TIMER_MAX: _bindgen_ty_3 = 35;
+pub const _SC_BC_BASE_MAX: _bindgen_ty_3 = 36;
+pub const _SC_BC_DIM_MAX: _bindgen_ty_3 = 37;
+pub const _SC_BC_SCALE_MAX: _bindgen_ty_3 = 38;
+pub const _SC_BC_STRING_MAX: _bindgen_ty_3 = 39;
+pub const _SC_COLL_WEIGHTS_MAX: _bindgen_ty_3 = 40;
+pub const _SC_EQUIV_CLASS_MAX: _bindgen_ty_3 = 41;
+pub const _SC_EXPR_NEST_MAX: _bindgen_ty_3 = 42;
+pub const _SC_LINE_MAX: _bindgen_ty_3 = 43;
+pub const _SC_RE_DUP_MAX: _bindgen_ty_3 = 44;
+pub const _SC_CHARCLASS_NAME_MAX: _bindgen_ty_3 = 45;
+pub const _SC_2_VERSION: _bindgen_ty_3 = 46;
+pub const _SC_2_C_BIND: _bindgen_ty_3 = 47;
+pub const _SC_2_C_DEV: _bindgen_ty_3 = 48;
+pub const _SC_2_FORT_DEV: _bindgen_ty_3 = 49;
+pub const _SC_2_FORT_RUN: _bindgen_ty_3 = 50;
+pub const _SC_2_SW_DEV: _bindgen_ty_3 = 51;
+pub const _SC_2_LOCALEDEF: _bindgen_ty_3 = 52;
+pub const _SC_SSIZE_MAX: _bindgen_ty_3 = 110;
+pub const _SC_SCHAR_MAX: _bindgen_ty_3 = 111;
+pub const _SC_SCHAR_MIN: _bindgen_ty_3 = 112;
+pub const _SC_SHRT_MAX: _bindgen_ty_3 = 113;
+pub const _SC_SHRT_MIN: _bindgen_ty_3 = 114;
+pub const _SC_UCHAR_MAX: _bindgen_ty_3 = 115;
+pub const _SC_UINT_MAX: _bindgen_ty_3 = 116;
+pub const _SC_ULONG_MAX: _bindgen_ty_3 = 117;
+pub const _SC_USHRT_MAX: _bindgen_ty_3 = 118;
+pub const _SC_NL_ARGMAX: _bindgen_ty_3 = 119;
+pub const _SC_NL_LANGMAX: _bindgen_ty_3 = 120;
+pub const _SC_NL_MSGMAX: _bindgen_ty_3 = 121;
+pub const _SC_NL_NMAX: _bindgen_ty_3 = 122;
+pub const _SC_NL_SETMAX: _bindgen_ty_3 = 123;
+pub const _SC_NL_TEXTMAX: _bindgen_ty_3 = 124;
+pub const _SC_XBS5_ILP32_OFF32: _bindgen_ty_3 = 125;
+pub const _SC_XBS5_ILP32_OFFBIG: _bindgen_ty_3 = 126;
+pub const _SC_XBS5_LP64_OFF64: _bindgen_ty_3 = 127;
+pub const _SC_XBS5_LPBIG_OFFBIG: _bindgen_ty_3 = 128;
+pub const _SC_XOPEN_LEGACY: _bindgen_ty_3 = 129;
+pub const _SC_XOPEN_REALTIME: _bindgen_ty_3 = 130;
+pub const _SC_XOPEN_REALTIME_THREADS: _bindgen_ty_3 = 131;
+pub const _SC_ADVISORY_INFO: _bindgen_ty_3 = 132;
+pub const _SC_BARRIERS: _bindgen_ty_3 = 133;
+pub const _SC_LEVEL1_ICACHE_SIZE: _bindgen_ty_3 = 185;
+pub const _SC_LEVEL1_ICACHE_ASSOC: _bindgen_ty_3 = 186;
+pub const _SC_LEVEL1_ICACHE_LINESIZE: _bindgen_ty_3 = 187;
+pub const _SC_LEVEL1_DCACHE_SIZE: _bindgen_ty_3 = 188;
+pub const _SC_LEVEL1_DCACHE_ASSOC: _bindgen_ty_3 = 189;
+pub const _SC_LEVEL1_DCACHE_LINESIZE: _bindgen_ty_3 = 190;
+pub const _SC_LEVEL2_CACHE_SIZE: _bindgen_ty_3 = 191;
+pub const _SC_LEVEL2_CACHE_ASSOC: _bindgen_ty_3 = 192;
+pub const _SC_LEVEL2_CACHE_LINESIZE: _bindgen_ty_3 = 193;
+pub const _SC_LEVEL3_CACHE_SIZE: _bindgen_ty_3 = 194;
+pub const _SC_LEVEL3_CACHE_ASSOC: _bindgen_ty_3 = 195;
+pub const _SC_LEVEL3_CACHE_LINESIZE: _bindgen_ty_3 = 196;
+pub const _SC_LEVEL4_CACHE_SIZE: _bindgen_ty_3 = 197;
+pub const _SC_LEVEL4_CACHE_ASSOC: _bindgen_ty_3 = 198;
+pub const _SC_LEVEL4_CACHE_LINESIZE: _bindgen_ty_3 = 199;
+
+extern "C" {
+ pub fn pathconf(
+ __path: *const ::std::os::raw::c_char,
+ __name: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn fpathconf(
+ __fd: ::std::os::raw::c_int,
+ __name: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn sysconf(__name: ::std::os::raw::c_int) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn confstr(
+ __name: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> usize;
+}
+extern "C" {
+ pub fn getpid() -> __pid_t;
+}
+extern "C" {
+ pub fn getppid() -> __pid_t;
+}
+extern "C" {
+ pub fn getpgrp() -> __pid_t;
+}
+extern "C" {
+ pub fn __getpgid(__pid: __pid_t) -> __pid_t;
+}
+extern "C" {
+ pub fn getpgid(__pid: __pid_t) -> __pid_t;
+}
+extern "C" {
+ pub fn setpgid(__pid: __pid_t, __pgid: __pid_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setpgrp() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setsid() -> __pid_t;
+}
+extern "C" {
+ pub fn getsid(__pid: __pid_t) -> __pid_t;
+}
+extern "C" {
+ pub fn getuid() -> __uid_t;
+}
+extern "C" {
+ pub fn geteuid() -> __uid_t;
+}
+extern "C" {
+ pub fn getgid() -> __gid_t;
+}
+extern "C" {
+ pub fn getegid() -> __gid_t;
+}
+extern "C" {
+ pub fn link(
+ __from: *const ::std::os::raw::c_char,
+ __to: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn linkat(
+ __fromfd: ::std::os::raw::c_int,
+ __from: *const ::std::os::raw::c_char,
+ __tofd: ::std::os::raw::c_int,
+ __to: *const ::std::os::raw::c_char,
+ __flags: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn symlink(
+ __from: *const ::std::os::raw::c_char,
+ __to: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn readlink(
+ __path: *const ::std::os::raw::c_char,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> isize;
+}
+extern "C" {
+ pub fn symlinkat(
+ __from: *const ::std::os::raw::c_char,
+ __tofd: ::std::os::raw::c_int,
+ __to: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn readlinkat(
+ __fd: ::std::os::raw::c_int,
+ __path: *const ::std::os::raw::c_char,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> isize;
+}
+extern "C" {
+ pub fn rmdir(__path: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn tcgetpgrp(__fd: ::std::os::raw::c_int) -> __pid_t;
+}
+extern "C" {
+ pub fn tcsetpgrp(__fd: ::std::os::raw::c_int, __pgrp_id: __pid_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getlogin() -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn getlogin_r(
+ __name: *mut ::std::os::raw::c_char,
+ __name_len: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setlogin(__name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}optarg"]
+ pub static mut optarg: *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ #[link_name = "\u{1}optind"]
+ pub static mut optind: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}opterr"]
+ pub static mut opterr: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}optopt"]
+ pub static mut optopt: ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getopt(
+ ___argc: ::std::os::raw::c_int,
+ ___argv: *const *mut ::std::os::raw::c_char,
+ __shortopts: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn gethostname(__name: *mut ::std::os::raw::c_char, __len: usize) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sethostname(
+ __name: *const ::std::os::raw::c_char,
+ __len: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn acct(__name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getusershell() -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn endusershell();
+}
+extern "C" {
+ pub fn setusershell();
+}
+extern "C" {
+ pub fn daemon(
+ __nochdir: ::std::os::raw::c_int,
+ __noclose: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn chroot(__path: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getpass(__prompt: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn fsync(__fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn syncfs(__fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lockf(
+ __fd: ::std::os::raw::c_int,
+ __cmd: ::std::os::raw::c_int,
+ __len: __off_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lockf64(
+ __fd: ::std::os::raw::c_int,
+ __cmd: ::std::os::raw::c_int,
+ __len: __off64_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn copy_file_range(
+ __infd: ::std::os::raw::c_int,
+ __pinoff: *mut __off64_t,
+ __outfd: ::std::os::raw::c_int,
+ __poutoff: *mut __off64_t,
+ __length: usize,
+ __flags: ::std::os::raw::c_uint,
+ ) -> isize;
+}
+extern "C" {
+ pub fn fdatasync(__fildes: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn crypt(
+ __key: *const ::std::os::raw::c_char,
+ __salt: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn swab(
+ __from: *const ::std::os::raw::c_void,
+ __to: *mut ::std::os::raw::c_void,
+ __n: isize,
+ );
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union siginfo_t__bindgen_ty_1 {
+ pub _pad: [::std::os::raw::c_int; 28usize],
+ pub _kill: siginfo_t__bindgen_ty_1__bindgen_ty_1,
+ pub _timer: siginfo_t__bindgen_ty_1__bindgen_ty_2,
+ pub _rt: siginfo_t__bindgen_ty_1__bindgen_ty_3,
+ pub _sigchld: siginfo_t__bindgen_ty_1__bindgen_ty_4,
+ pub _sigfault: siginfo_t__bindgen_ty_1__bindgen_ty_5,
+ pub _sigpoll: siginfo_t__bindgen_ty_1__bindgen_ty_6,
+ pub _sigsys: siginfo_t__bindgen_ty_1__bindgen_ty_7,
+ _bindgen_union_align: [u64; 14usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_1 {
+ pub si_pid: __pid_t,
+ pub si_uid: __uid_t,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_2 {
+ pub si_tid: ::std::os::raw::c_int,
+ pub si_overrun: ::std::os::raw::c_int,
+ pub si_sigval: __sigval_t,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_5 {
+ pub si_addr: *mut ::std::os::raw::c_void,
+ pub si_addr_lsb: ::std::os::raw::c_short,
+ pub _bounds: siginfo_t__bindgen_ty_1__bindgen_ty_5__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union siginfo_t__bindgen_ty_1__bindgen_ty_5__bindgen_ty_1 {
+ pub _addr_bnd: siginfo_t__bindgen_ty_1__bindgen_ty_5__bindgen_ty_1__bindgen_ty_1,
+ pub _pkey: __uint32_t,
+ _bindgen_union_align: [u64; 2usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_5__bindgen_ty_1__bindgen_ty_1 {
+ pub _lower: *mut ::std::os::raw::c_void,
+ pub _upper: *mut ::std::os::raw::c_void,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_6 {
+ pub si_band: ::std::os::raw::c_long,
+ pub si_fd: ::std::os::raw::c_int,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct siginfo_t__bindgen_ty_1__bindgen_ty_7 {
+ pub _call_addr: *mut ::std::os::raw::c_void,
+ pub _syscall: ::std::os::raw::c_int,
+ pub _arch: ::std::os::raw::c_uint,
+}
+pub const ILL_ILLOPC: _bindgen_ty_6 = 1;
+pub const ILL_ILLOPN: _bindgen_ty_6 = 2;
+pub const ILL_ILLADR: _bindgen_ty_6 = 3;
+pub const ILL_ILLTRP: _bindgen_ty_6 = 4;
+pub const ILL_PRVOPC: _bindgen_ty_6 = 5;
+pub const ILL_PRVREG: _bindgen_ty_6 = 6;
+pub const ILL_COPROC: _bindgen_ty_6 = 7;
+pub const ILL_BADSTK: _bindgen_ty_6 = 8;
+
+pub const POLL_IN: _bindgen_ty_12 = 1;
+pub const POLL_OUT: _bindgen_ty_12 = 2;
+pub const POLL_MSG: _bindgen_ty_12 = 3;
+pub const POLL_ERR: _bindgen_ty_12 = 4;
+pub const POLL_PRI: _bindgen_ty_12 = 5;
+pub const POLL_HUP: _bindgen_ty_12 = 6;
+pub type _bindgen_ty_12 = u32;
+pub type sigval_t = __sigval_t;
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct sigevent {
+ pub sigev_value: __sigval_t,
+ pub sigev_signo: ::std::os::raw::c_int,
+ pub sigev_notify: ::std::os::raw::c_int,
+ pub _sigev_un: sigevent__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union sigevent__bindgen_ty_1 {
+ pub _pad: [::std::os::raw::c_int; 12usize],
+ pub _tid: __pid_t,
+ pub _sigev_thread: sigevent__bindgen_ty_1__bindgen_ty_1,
+ _bindgen_union_align: [u64; 6usize],
+}
+extern "C" {
+ pub fn __sysv_signal(__sig: ::std::os::raw::c_int, __handler: __sighandler_t)
+ -> __sighandler_t;
+}
+extern "C" {
+ pub fn sysv_signal(__sig: ::std::os::raw::c_int, __handler: __sighandler_t) -> __sighandler_t;
+}
+extern "C" {
+ pub fn signal(__sig: ::std::os::raw::c_int, __handler: __sighandler_t) -> __sighandler_t;
+}
+extern "C" {
+ #[link_name = "\u{1}__xpg_sigpause"]
+ pub fn sigpause(__sig: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigblock(__mask: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigsetmask(__mask: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn siggetmask() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigandset(
+ __set: *mut sigset_t,
+ __left: *const sigset_t,
+ __right: *const sigset_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigorset(
+ __set: *mut sigset_t,
+ __left: *const sigset_t,
+ __right: *const sigset_t,
+ ) -> ::std::os::raw::c_int;
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct sigaction {
+ pub __sigaction_handler: sigaction__bindgen_ty_1,
+ pub sa_mask: __sigset_t,
+ pub sa_flags: ::std::os::raw::c_int,
+ pub sa_restorer: ::core::option::Option,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union sigaction__bindgen_ty_1 {
+ pub sa_handler: __sighandler_t,
+ pub sa_sigaction: ::core::option::Option<
+ unsafe extern "C" fn(
+ arg1: ::std::os::raw::c_int,
+ arg2: *mut siginfo_t,
+ arg3: *mut ::std::os::raw::c_void,
+ ),
+ >,
+ _bindgen_union_align: u64,
+}
+extern "C" {
+ pub fn sigprocmask(
+ __how: ::std::os::raw::c_int,
+ __set: *const sigset_t,
+ __oset: *mut sigset_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigsuspend(__set: *const sigset_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigaction(
+ __sig: ::std::os::raw::c_int,
+ __act: *const sigaction,
+ __oact: *mut sigaction,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigpending(__set: *mut sigset_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigwait(
+ __set: *const sigset_t,
+ __sig: *mut ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigwaitinfo(__set: *const sigset_t, __info: *mut siginfo_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigtimedwait(
+ __set: *const sigset_t,
+ __info: *mut siginfo_t,
+ __timeout: *const timespec,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sigqueue(
+ __pid: __pid_t,
+ __sig: ::std::os::raw::c_int,
+ __val: sigval,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}_sys_siglist"]
+ pub static mut _sys_siglist: [*const ::std::os::raw::c_char; 65usize];
+}
+extern "C" {
+ #[link_name = "\u{1}sys_siglist"]
+ pub static mut sys_siglist: [*const ::std::os::raw::c_char; 65usize];
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct _fpx_sw_bytes {
+ pub magic1: __uint32_t,
+ pub extended_size: __uint32_t,
+ pub xstate_bv: __uint64_t,
+ pub xstate_size: __uint32_t,
+ pub __glibc_reserved1: [__uint32_t; 7usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct _fpreg {
+ pub significand: [::std::os::raw::c_ushort; 4usize],
+ pub exponent: ::std::os::raw::c_ushort,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct sigcontext {
+ pub r8: __uint64_t,
+ pub r9: __uint64_t,
+ pub r10: __uint64_t,
+ pub r11: __uint64_t,
+ pub r12: __uint64_t,
+ pub r13: __uint64_t,
+ pub r14: __uint64_t,
+ pub r15: __uint64_t,
+ pub rdi: __uint64_t,
+ pub rsi: __uint64_t,
+ pub rbp: __uint64_t,
+ pub rbx: __uint64_t,
+ pub rdx: __uint64_t,
+ pub rax: __uint64_t,
+ pub rcx: __uint64_t,
+ pub rsp: __uint64_t,
+ pub rip: __uint64_t,
+ pub eflags: __uint64_t,
+ pub cs: ::std::os::raw::c_ushort,
+ pub gs: ::std::os::raw::c_ushort,
+ pub fs: ::std::os::raw::c_ushort,
+ pub __pad0: ::std::os::raw::c_ushort,
+ pub err: __uint64_t,
+ pub trapno: __uint64_t,
+ pub oldmask: __uint64_t,
+ pub cr2: __uint64_t,
+ pub __bindgen_anon_1: sigcontext__bindgen_ty_1,
+ pub __reserved1: [__uint64_t; 8usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union sigcontext__bindgen_ty_1 {
+ pub fpstate: *mut _fpstate,
+ pub __fpstate_word: __uint64_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct _libc_fpstate {
+ pub cwd: __uint16_t,
+ pub swd: __uint16_t,
+ pub ftw: __uint16_t,
+ pub fop: __uint16_t,
+ pub rip: __uint64_t,
+ pub rdp: __uint64_t,
+ pub mxcsr: __uint32_t,
+ pub mxcr_mask: __uint32_t,
+ pub _st: [_libc_fpxreg; 8usize],
+ pub _xmm: [_libc_xmmreg; 16usize],
+ pub __glibc_reserved1: [__uint32_t; 24usize],
+}
+#[derive(Debug, Copy, Clone)]
+pub struct ucontext_t {
+ pub uc_flags: ::std::os::raw::c_ulong,
+ pub uc_link: *mut ucontext_t,
+ pub uc_stack: stack_t,
+ pub uc_mcontext: mcontext_t,
+ pub uc_sigmask: sigset_t,
+ pub __fpregs_mem: _libc_fpstate,
+ pub __ssp: [::std::os::raw::c_ulonglong; 4usize],
+}
+extern "C" {
+ pub fn siginterrupt(
+ __sig: ::std::os::raw::c_int,
+ __interrupt: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+pub const SS_ONSTACK: _bindgen_ty_15 = 1;
+pub const SS_DISABLE: _bindgen_ty_15 = 2;
+pub type _bindgen_ty_15 = u32;
+extern "C" {
+ pub fn sigaltstack(__ss: *const stack_t, __oss: *mut stack_t) -> ::std::os::raw::c_int;
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct __pthread_cond_s {
+ pub __bindgen_anon_1: __pthread_cond_s__bindgen_ty_1,
+ pub __bindgen_anon_2: __pthread_cond_s__bindgen_ty_2,
+ pub __g_refs: [::std::os::raw::c_uint; 2usize],
+ pub __g_size: [::std::os::raw::c_uint; 2usize],
+ pub __g1_orig_size: ::std::os::raw::c_uint,
+ pub __wrefs: ::std::os::raw::c_uint,
+ pub __g_signals: [::std::os::raw::c_uint; 2usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_mutex_t {
+ pub __data: __pthread_mutex_s,
+ pub __size: [::std::os::raw::c_char; 40usize],
+ pub __align: ::std::os::raw::c_long,
+ _bindgen_union_align: [u64; 5usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_cond_t {
+ pub __data: __pthread_cond_s,
+ pub __size: [::std::os::raw::c_char; 48usize],
+ pub __align: ::std::os::raw::c_longlong,
+ _bindgen_union_align: [u64; 6usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_rwlock_t {
+ pub __data: __pthread_rwlock_arch_t,
+ pub __size: [::std::os::raw::c_char; 56usize],
+ pub __align: ::std::os::raw::c_long,
+ _bindgen_union_align: [u64; 7usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_rwlockattr_t {
+ pub __size: [::std::os::raw::c_char; 8usize],
+ pub __align: ::std::os::raw::c_long,
+ _bindgen_union_align: u64,
+}
+pub type pthread_spinlock_t = ::std::os::raw::c_int;
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_barrier_t {
+ pub __size: [::std::os::raw::c_char; 32usize],
+ pub __align: ::std::os::raw::c_long,
+ _bindgen_union_align: [u64; 4usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union pthread_barrierattr_t {
+ pub __size: [::std::os::raw::c_char; 4usize],
+ pub __align: ::std::os::raw::c_int,
+ _bindgen_union_align: u32,
+}
+pub const r_instruction_r_output_direction: r_instruction = 0;
+pub const r_instruction_r_input_direction: r_instruction = 1;
+pub const r_instruction_r_inputa_direction: r_instruction = 2;
+pub const r_instruction_r_appending_to: r_instruction = 3;
+pub const r_instruction_r_reading_until: r_instruction = 4;
+pub const r_instruction_r_reading_string: r_instruction = 5;
+pub const r_instruction_r_duplicating_input: r_instruction = 6;
+pub const r_instruction_r_duplicating_output: r_instruction = 7;
+pub const r_instruction_r_deblank_reading_until: r_instruction = 8;
+pub type REDIRECT = redirect;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct element {
+ pub word: *mut WORD_DESC,
+ pub redirect: *mut REDIRECT,
+}
+pub type ELEMENT = element;
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct command {
+ pub type_: command_type,
+ pub flags: ::std::os::raw::c_int,
+ pub line: ::std::os::raw::c_int,
+ pub redirects: *mut REDIRECT,
+ pub value: command__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union command__bindgen_ty_1 {
+ pub For: *mut for_com,
+ pub Case: *mut case_com,
+ pub While: *mut while_com,
+ pub If: *mut if_com,
+ pub Connection: *mut connection,
+ pub Simple: *mut simple_com,
+ pub Function_def: *mut function_def,
+ pub Group: *mut group_com,
+ pub Select: *mut select_com,
+ pub Arith: *mut arith_com,
+ pub Cond: *mut cond_com,
+ pub ArithFor: *mut arith_for_com,
+ pub Subshell: *mut subshell_com,
+ pub Coproc: *mut coproc_com,
+ _bindgen_union_align: u64,
+}
+pub type COMMAND = command;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct connection {
+ pub ignore: ::std::os::raw::c_int,
+ pub first: *mut COMMAND,
+ pub second: *mut COMMAND,
+ pub connector: ::std::os::raw::c_int,
+}
+pub type CONNECTION = connection;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct pattern_list {
+ pub next: *mut pattern_list,
+ pub patterns: *mut WORD_LIST,
+ pub action: *mut COMMAND,
+ pub flags: ::std::os::raw::c_int,
+}
+pub type PATTERN_LIST = pattern_list;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct case_com {
+ pub flags: ::std::os::raw::c_int,
+ pub line: ::std::os::raw::c_int,
+ pub word: *mut WORD_DESC,
+ pub clauses: *mut PATTERN_LIST,
+}
+pub type CASE_COM = case_com;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct for_com {
+ pub flags: ::std::os::raw::c_int,
+ pub line: ::std::os::raw::c_int,
+ pub name: *mut WORD_DESC,
+ pub map_list: *mut WORD_LIST,
+ pub action: *mut COMMAND,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct if_com {
+ pub flags: ::std::os::raw::c_int,
+ pub test: *mut COMMAND,
+ pub true_case: *mut COMMAND,
+ pub false_case: *mut COMMAND,
+}
+pub type IF_COM = if_com;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct while_com {
+ pub flags: ::std::os::raw::c_int,
+ pub test: *mut COMMAND,
+ pub action: *mut COMMAND,
+}
+pub type SIMPLE_COM = simple_com;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct function_def {
+ pub flags: ::std::os::raw::c_int,
+ pub line: ::std::os::raw::c_int,
+ pub name: *mut WORD_DESC,
+ pub command: *mut COMMAND,
+ pub source_file: *mut ::std::os::raw::c_char,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct coproc {
+ pub c_name: *mut ::std::os::raw::c_char,
+ pub c_pid: pid_t,
+ pub c_rfd: ::std::os::raw::c_int,
+ pub c_wfd: ::std::os::raw::c_int,
+ pub c_rsave: ::std::os::raw::c_int,
+ pub c_wsave: ::std::os::raw::c_int,
+ pub c_flags: ::std::os::raw::c_int,
+ pub c_status: ::std::os::raw::c_int,
+ pub c_lock: ::std::os::raw::c_int,
+}
+extern "C" {
+ #[link_name = "\u{1}global_command"]
+ pub static mut global_command: *mut COMMAND;
+}
+extern "C" {
+ #[link_name = "\u{1}sh_coproc"]
+ pub static mut sh_coproc: Coproc;
+}
+pub type ulong = ::std::os::raw::c_ulong;
+pub type ushort = ::std::os::raw::c_ushort;
+pub type uint = ::std::os::raw::c_uint;
+pub type u_int8_t = ::std::os::raw::c_uchar;
+pub type u_int16_t = ::std::os::raw::c_ushort;
+pub type u_int32_t = ::std::os::raw::c_uint;
+pub type u_int64_t = ::std::os::raw::c_ulong;
+pub type register_t = ::std::os::raw::c_long;
+extern "C" {
+ pub fn strtoumax(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __base: ::std::os::raw::c_int,
+ ) -> uintmax_t;
+}
+extern "C" {
+ pub fn wcstoimax(
+ __nptr: *const __gwchar_t,
+ __endptr: *mut *mut __gwchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> intmax_t;
+}
+extern "C" {
+ pub fn wcstoumax(
+ __nptr: *const __gwchar_t,
+ __endptr: *mut *mut __gwchar_t,
+ __base: ::std::os::raw::c_int,
+ ) -> uintmax_t;
+}
+pub const _ISupper: _bindgen_ty_16 = 256;
+pub const _ISlower: _bindgen_ty_16 = 512;
+pub const _ISalpha: _bindgen_ty_16 = 1024;
+pub const _ISdigit: _bindgen_ty_16 = 2048;
+pub const _ISxdigit: _bindgen_ty_16 = 4096;
+pub const _ISspace: _bindgen_ty_16 = 8192;
+pub const _ISprint: _bindgen_ty_16 = 16384;
+pub const _ISgraph: _bindgen_ty_16 = 32768;
+pub const _ISblank: _bindgen_ty_16 = 1;
+pub const _IScntrl: _bindgen_ty_16 = 2;
+pub const _ISpunct: _bindgen_ty_16 = 4;
+pub const _ISalnum: _bindgen_ty_16 = 8;
+extern "C" {
+ pub fn isctype(
+ __c: ::std::os::raw::c_int,
+ __mask: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isascii(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn toascii(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn _toupper(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn _tolower(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isalnum_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isalpha_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn iscntrl_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isdigit_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn islower_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isgraph_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn isprint_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}pub fn isalpha_l(arg1: ::std::os::raw::c_int, arg2: locale_t) -> ::std::os::raw::c_int;
+}
+pub type __timezone_ptr_t = *mut timezone;
+extern "C" {
+ pub fn gettimeofday(__tv: *mut timeval, __tz: __timezone_ptr_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn settimeofday(__tv: *const timeval, __tz: *const timezone) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn adjtime(__delta: *const timeval, __olddelta: *mut timeval) -> ::std::os::raw::c_int;
+}
+pub const __itimer_which_ITIMER_REAL: __itimer_which = 0;
+pub const __itimer_which_ITIMER_VIRTUAL: __itimer_which = 1;
+pub const __itimer_which_ITIMER_PROF: __itimer_which = 2;
+pub type __itimer_which = u32;
+pub const __rlimit_resource_RLIMIT_CPU: __rlimit_resource = 0;
+pub const __rlimit_resource_RLIMIT_FSIZE: __rlimit_resource = 1;
+pub const __rlimit_resource_RLIMIT_DATA: __rlimit_resource = 2;
+pub const __rlimit_resource_RLIMIT_STACK: __rlimit_resource = 3;
+pub const __rlimit_resource_RLIMIT_CORE: __rlimit_resource = 4;
+pub const __rlimit_resource___RLIMIT_RSS: __rlimit_resource = 5;
+pub const __rlimit_resource_RLIMIT_NOFILE: __rlimit_resource = 7;
+pub const __rlimit_resource___RLIMIT_OFILE: __rlimit_resource = 7;
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct rusage {
+ pub ru_utime: timeval,
+ pub ru_stime: timeval,
+ pub __bindgen_anon_1: rusage__bindgen_ty_1,
+ pub __bindgen_anon_2: rusage__bindgen_ty_2,
+ pub __bindgen_anon_3: rusage__bindgen_ty_3,
+ pub __bindgen_anon_4: rusage__bindgen_ty_4,
+ pub __bindgen_anon_5: rusage__bindgen_ty_5,
+ pub __bindgen_anon_6: rusage__bindgen_ty_6,
+ pub __bindgen_anon_7: rusage__bindgen_ty_7,
+ pub __bindgen_anon_8: rusage__bindgen_ty_8,
+ pub __bindgen_anon_9: rusage__bindgen_ty_9,
+ pub __bindgen_anon_10: rusage__bindgen_ty_10,
+ pub __bindgen_anon_11: rusage__bindgen_ty_11,
+ pub __bindgen_anon_12: rusage__bindgen_ty_12,
+ pub __bindgen_anon_13: rusage__bindgen_ty_13,
+ pub __bindgen_anon_14: rusage__bindgen_ty_14,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_2 {
+ pub ru_ixrss: ::std::os::raw::c_long,
+ pub __ru_ixrss_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_3 {
+ pub ru_idrss: ::std::os::raw::c_long,
+ pub __ru_idrss_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_6 {
+ pub ru_majflt: ::std::os::raw::c_long,
+ pub __ru_majflt_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_7 {
+ pub ru_nswap: ::std::os::raw::c_long,
+ pub __ru_nswap_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_8 {
+ pub ru_inblock: ::std::os::raw::c_long,
+ pub __ru_inblock_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_13 {
+ pub ru_nvcsw: ::std::os::raw::c_long,
+ pub __ru_nvcsw_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub union rusage__bindgen_ty_14 {
+ pub ru_nivcsw: ::std::os::raw::c_long,
+ pub __ru_nivcsw_word: __syscall_slong_t,
+ _bindgen_union_align: u64,
+}
+pub const __priority_which_PRIO_PROCESS: __priority_which = 0;
+pub const __priority_which_PRIO_PGRP: __priority_which = 1;
+pub const __priority_which_PRIO_USER: __priority_which = 2;
+pub type __priority_which = u32;
+extern "C" {
+ pub fn prlimit(
+ __pid: __pid_t,
+ __resource: __rlimit_resource,
+ __new_limit: *const rlimit,
+ __old_limit: *mut rlimit,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getrlimit64(
+ __resource: __rlimit_resource_t,
+ __rlimits: *mut rlimit64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setrlimit(
+ __resource: __rlimit_resource_t,
+ __rlimits: *const rlimit,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setrlimit64(
+ __resource: __rlimit_resource_t,
+ __rlimits: *const rlimit64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getrusage(__who: __rusage_who_t, __usage: *mut rusage) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn getpriority(__which: __priority_which_t, __who: id_t) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn memccpy(
+ __dest: *mut ::std::os::raw::c_void,
+ __src: *const ::std::os::raw::c_void,
+ __c: ::std::os::raw::c_int,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn memset(
+ __s: *mut ::std::os::raw::c_void,
+ __c: ::std::os::raw::c_int,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+
+
+extern "C" {
+ pub fn strcpy(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strncpy(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strcat(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strncat(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strcmp(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strncmp(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strcoll(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strxfrm(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn strcoll_l(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ __l: locale_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strxfrm_l(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ __l: locale_t,
+ ) -> usize;
+}
+extern "C" {
+ pub fn strdup(__s: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strndup(
+ __string: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strchr(
+ __s: *const ::std::os::raw::c_char,
+ __c: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strrchr(
+ __s: *const ::std::os::raw::c_char,
+ __c: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strchrnul(
+ __s: *const ::std::os::raw::c_char,
+ __c: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strcspn(
+ __s: *const ::std::os::raw::c_char,
+ __reject: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn strspn(
+ __s: *const ::std::os::raw::c_char,
+ __accept: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn strpbrk(
+ __s: *const ::std::os::raw::c_char,
+ __accept: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strstr(
+ __haystack: *const ::std::os::raw::c_char,
+ __needle: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strtok(
+ __s: *mut ::std::os::raw::c_char,
+ __delim: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn __strtok_r(
+ __s: *mut ::std::os::raw::c_char,
+ __delim: *const ::std::os::raw::c_char,
+ __save_ptr: *mut *mut ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strtok_r(
+ __s: *mut ::std::os::raw::c_char,
+ __delim: *const ::std::os::raw::c_char,
+ __save_ptr: *mut *mut ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strcasestr(
+ __haystack: *const ::std::os::raw::c_char,
+ __needle: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn memmem(
+ __haystack: *const ::std::os::raw::c_void,
+ __haystacklen: usize,
+ __needle: *const ::std::os::raw::c_void,
+ __needlelen: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn __mempcpy(
+ __dest: *mut ::std::os::raw::c_void,
+ __src: *const ::std::os::raw::c_void,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn mempcpy(
+ __dest: *mut ::std::os::raw::c_void,
+ __src: *const ::std::os::raw::c_void,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn strncmp(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strerror_l(
+ __errnum: ::std::os::raw::c_int,
+ __l: locale_t,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn bcmp(
+ __s1: *const ::std::os::raw::c_void,
+ __s2: *const ::std::os::raw::c_void,
+ __n: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strcoll(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strlen(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_ulong;
+}
+extern "C" {
+ pub fn strnlen(__string: *const ::std::os::raw::c_char, __maxlen: usize) -> usize;
+}
+extern "C" {
+ pub fn explicit_bzero(__s: *mut ::std::os::raw::c_void, __n: usize);
+}
+extern "C" {
+ pub fn strncasecmp_l(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ __n: usize,
+ __loc: locale_t,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strerror(__errnum: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn stpcpy(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn __stpncpy(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn stpncpy(
+ __dest: *mut ::std::os::raw::c_char,
+ __src: *const ::std::os::raw::c_char,
+ __n: usize,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn strverscmp(
+ __s1: *const ::std::os::raw::c_char,
+ __s2: *const ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct lldiv_t {
+ pub quot: ::std::os::raw::c_longlong,
+ pub rem: ::std::os::raw::c_longlong,
+}
+extern "C" {
+ pub fn __ctype_get_mb_cur_max() -> usize;
+}
+extern "C" {
+ pub fn atof(__nptr: *const ::std::os::raw::c_char) -> f64;
+}
+extern "C" {
+ pub fn atoi(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn atol(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn atoll(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_longlong;
+}
+extern "C" {
+ pub fn strtof32(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ ) -> _Float32;
+}
+extern "C" {
+ pub fn strtof64(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ ) -> _Float64;
+}
+extern "C" {
+ pub fn strtof32x(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ ) -> _Float32x;
+}
+extern "C" {
+ pub fn strtof64x(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ ) -> _Float64x;
+}
+extern "C" {
+ pub fn strtoq(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_longlong;
+}
+extern "C" {
+ pub fn strtouq(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __base: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_ulonglong;
+}
+extern "C" {
+ pub fn strfromd(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: f64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfromf(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: f32,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfroml(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: f64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfromf32(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: _Float32,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfromf64(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: _Float64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfromf32x(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: _Float32x,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strfromf64x(
+ __dest: *mut ::std::os::raw::c_char,
+ __size: usize,
+ __format: *const ::std::os::raw::c_char,
+ __f: _Float64x,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn strtold_l(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __loc: locale_t,
+ ) -> f64;
+}
+extern "C" {
+ pub fn strtof32_l(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __loc: locale_t,
+ ) -> _Float32;
+}
+extern "C" {
+ pub fn strtof64_l(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __loc: locale_t,
+ ) -> _Float64;
+}
+extern "C" {
+ pub fn strtof32x_l(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __loc: locale_t,
+ ) -> _Float32x;
+}
+extern "C" {
+ pub fn strtof64x_l(
+ __nptr: *const ::std::os::raw::c_char,
+ __endptr: *mut *mut ::std::os::raw::c_char,
+ __loc: locale_t,
+ ) -> _Float64x;
+}
+extern "C" {
+ pub fn l64a(__n: ::std::os::raw::c_long) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn a64l(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn random() -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn srandom(__seed: ::std::os::raw::c_uint);
+}
+extern "C" {
+ pub fn initstate_r(
+ __seed: ::std::os::raw::c_uint,
+ __statebuf: *mut ::std::os::raw::c_char,
+ __statelen: usize,
+ __buf: *mut random_data,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn setstate_r(
+ __statebuf: *mut ::std::os::raw::c_char,
+ __buf: *mut random_data,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn rand() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn srand(__seed: ::std::os::raw::c_uint);
+}
+extern "C" {
+ pub fn rand_r(__seed: *mut ::std::os::raw::c_uint) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lcong48(__param: *mut ::std::os::raw::c_ushort);
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct drand48_data {
+ pub __x: [::std::os::raw::c_ushort; 3usize],
+ pub __old_x: [::std::os::raw::c_ushort; 3usize],
+ pub __c: ::std::os::raw::c_ushort,
+ pub __init: ::std::os::raw::c_ushort,
+ pub __a: ::std::os::raw::c_ulonglong,
+}
+extern "C" {
+ pub fn drand48_r(__buffer: *mut drand48_data, __result: *mut f64) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn erand48_r(
+ __xsubi: *mut ::std::os::raw::c_ushort,
+ __buffer: *mut drand48_data,
+ __result: *mut f64,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lrand48_r(
+ __buffer: *mut drand48_data,
+ __result: *mut ::std::os::raw::c_long,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn nrand48_r(
+ __xsubi: *mut ::std::os::raw::c_ushort,
+ __buffer: *mut drand48_data,
+ __result: *mut ::std::os::raw::c_long,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn seed48_r(
+ __seed16v: *mut ::std::os::raw::c_ushort,
+ __buffer: *mut drand48_data,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn lcong48_r(
+ __param: *mut ::std::os::raw::c_ushort,
+ __buffer: *mut drand48_data,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn malloc(__size: usize) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn calloc(__nmemb: usize, __size: usize) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn realloc(
+ __ptr: *mut ::std::os::raw::c_void,
+ __size: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn reallocarray(
+ __ptr: *mut ::std::os::raw::c_void,
+ __nmemb: usize,
+ __size: usize,
+ ) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn free(__ptr: *mut ::std::os::raw::c_void);
+}
+extern "C" {
+ pub fn alloca(__size: usize) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn valloc(__size: usize) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn exit(__status: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn quick_exit(__status: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn _Exit(__status: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn getenv(__name: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn secure_getenv(__name: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn putenv(__string: *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn aligned_alloc(__alignment: usize, __size: usize) -> *mut ::std::os::raw::c_void;
+}
+extern "C" {
+ pub fn abort();
+}
+extern "C" {
+ pub fn atexit(__func: ::core::option::Option) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn unsetenv(__name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn clearenv() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn at_quick_exit(
+ __func: ::core::option::Option,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn mkstemps64(
+ __template: *mut ::std::os::raw::c_char,
+ __suffixlen: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn mkdtemp(__template: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn mkostemp(
+ __template: *mut ::std::os::raw::c_char,
+ __flags: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn system(__command: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn canonicalize_file_name(
+ __name: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn fcvt(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn gcvt(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn qecvt(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn qfcvt(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn qgcvt(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn ecvt_r(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fcvt_r(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn qecvt_r(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn qfcvt_r(
+ __value: f64,
+ __ndigit: ::std::os::raw::c_int,
+ __decpt: *mut ::std::os::raw::c_int,
+ __sign: *mut ::std::os::raw::c_int,
+ __buf: *mut ::std::os::raw::c_char,
+ __len: usize,
+ ) -> ::std::os::raw::c_int;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct g_list {
+ pub next: *mut g_list,
+}
+pub type GENERIC_LIST = g_list;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct STRING_INT_ALIST {
+ pub word: *mut ::std::os::raw::c_char,
+ pub token: ::std::os::raw::c_int,
+}
+pub type Function = ::core::option::Option ::std::os::raw::c_int>;
+pub type VFunction = ::core::option::Option;
+pub type CPFunction = ::core::option::Option *mut ::std::os::raw::c_char>;
+pub type CPPFunction =
+ ::core::option::Option *mut *mut ::std::os::raw::c_char>;
+pub type sh_intfunc_t = ::core::option::Option<
+ unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int,
+>;
+pub type sh_ivoidfunc_t = ::core::option::Option ::std::os::raw::c_int>;
+pub type sh_icpfunc_t = ::core::option::Option<
+ unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int,
+>;
+pub type sh_icppfunc_t = ::core::option::Option<
+ unsafe extern "C" fn(arg1: *mut *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int,
+>;
+pub type sh_iptrfunc_t = ::core::option::Option<
+ unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
+>;
+pub type sh_wassign_func_t = ::core::option::Option<
+ unsafe extern "C" fn(
+ arg1: *mut WORD_DESC,
+ arg2: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int,
+>;
+pub type sh_load_func_t = ::core::option::Option<
+ unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int,
+>;
+pub type sh_unload_func_t =
+ ::core::option::Option;
+pub type sh_builtin_func_t =
+ ::core::option::Option ::std::os::raw::c_int>;
+pub type QSFUNC = ::core::option::Option<
+ unsafe extern "C" fn(
+ arg1: *const ::std::os::raw::c_void,
+ arg2: *const ::std::os::raw::c_void,
+ ) -> ::std::os::raw::c_int,
+>;
+extern "C" {
+ pub fn posix_initialize(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn num_posix_options() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn get_posix_options(arg1: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn set_posix_options(arg1: *const ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn save_posix_options();
+}
+extern "C" {
+ pub fn string_to_rlimtype(arg1: *mut ::std::os::raw::c_char) -> rlim_t;
+}
+extern "C" {
+ pub fn print_rlimtype(arg1: rlim_t, arg2: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn all_digits(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn legal_identifier(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn importable_function_name(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: usize,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn exportable_function_name(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn check_identifier(
+ arg1: *mut WORD_DESC,
+ arg2: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn valid_nameref_value(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+ pub fn sh_unset_nodelay_mode(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sh_setclexec(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sh_validfd(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn fd_ispipe(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn check_dev_tty();
+}
+extern "C" {
+ pub fn move_to_high_fd(
+ arg1: ::std::os::raw::c_int,
+ arg2: ::std::os::raw::c_int,
+ arg3: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn check_binary_file(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sh_openpipe(arg1: *mut ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn sh_closepipe(arg1: *mut ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn file_exists(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn file_isdir(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn file_iswdir(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn path_dot_or_dotdot(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn absolute_pathname(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn absolute_program(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn make_absolute(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: *const ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn base_pathname(arg1: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn full_pathname(arg1: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn polite_directory_format(
+ arg1: *mut ::std::os::raw::c_char,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn trim_pathname(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn printable_filename(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn extract_colon_unit(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: *mut ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn tilde_initialize();
+}
+extern "C" {
+ pub fn bash_tilde_find_word(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ arg3: *mut ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn bash_tilde_expand(
+ arg1: *const ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn get_group_list(arg1: *mut ::std::os::raw::c_int) -> *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn get_group_array(arg1: *mut ::std::os::raw::c_int) -> *mut ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn conf_standard_path() -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn default_columns() -> ::std::os::raw::c_int;
+}
+pub type arrayind_t = intmax_t;
+pub const atype_array_indexed: atype = 0;
+pub const atype_array_assoc: atype = 1;
+pub type atype = u32;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct array {
+ pub type_: atype,
+ pub max_index: arrayind_t,
+ pub num_elements: ::std::os::raw::c_int,
+ pub head: *mut array_element,
+ pub lastref: *mut array_element,
+}
+pub type ARRAY = array;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct array_element {
+ pub ind: arrayind_t,
+ pub value: *mut ::std::os::raw::c_char,
+ pub next: *mut array_element,
+ pub prev: *mut array_element,
+}
+pub type ARRAY_ELEMENT = array_element;
+pub type sh_ae_map_func_t = ::core::option::Option<
+ unsafe extern "C" fn(
+ arg1: *mut ARRAY_ELEMENT,
+ arg2: *mut ::std::os::raw::c_void,
+ ) -> ::std::os::raw::c_int,
+>;
+extern "C" {
+ pub fn array_create() -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_flush(arg1: *mut ARRAY);
+}
+extern "C" {
+ pub fn array_dispose(arg1: *mut ARRAY);
+}
+extern "C" {
+ pub fn array_copy(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_slice(
+ arg1: *mut ARRAY,
+ arg2: *mut ARRAY_ELEMENT,
+ arg3: *mut ARRAY_ELEMENT,
+ ) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_walk(arg1: *mut ARRAY, arg2: sh_ae_map_func_t, arg3: *mut ::std::os::raw::c_void);
+}
+extern "C" {
+ pub fn array_shift(
+ arg1: *mut ARRAY,
+ arg2: ::std::os::raw::c_int,
+ arg3: ::std::os::raw::c_int,
+ ) -> *mut ARRAY_ELEMENT;
+}
+extern "C" {
+ pub fn array_rshift(
+ arg1: *mut ARRAY,
+ arg2: ::std::os::raw::c_int,
+ arg3: *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn array_unshift_element(arg1: *mut ARRAY) -> *mut ARRAY_ELEMENT;
+}
+extern "C" {
+ pub fn array_shift_element(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn array_quote(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_quote_escapes(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_dequote(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_dequote_escapes(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_remove_quoted_nulls(arg1: *mut ARRAY) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_subrange(
+ arg1: *mut ARRAY,
+ arg2: arrayind_t,
+ arg3: arrayind_t,
+ arg4: ::std::os::raw::c_int,
+ arg5: ::std::os::raw::c_int,
+ arg6: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_patsub(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: *mut ::std::os::raw::c_char,
+ arg4: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_modcase(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: ::std::os::raw::c_int,
+ arg4: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_create_element(
+ arg1: arrayind_t,
+ arg2: *mut ::std::os::raw::c_char,
+ ) -> *mut ARRAY_ELEMENT;
+}
+extern "C" {
+ pub fn array_copy_element(arg1: *mut ARRAY_ELEMENT) -> *mut ARRAY_ELEMENT;
+}
+extern "C" {
+ pub fn array_dispose_element(arg1: *mut ARRAY_ELEMENT);
+}
+extern "C" {
+ pub fn array_insert(
+ arg1: *mut ARRAY,
+ arg2: arrayind_t,
+ arg3: *mut ::std::os::raw::c_char,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn array_remove(arg1: *mut ARRAY, arg2: arrayind_t) -> *mut ARRAY_ELEMENT;
+}
+extern "C" {
+ pub fn array_reference(arg1: *mut ARRAY, arg2: arrayind_t) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_to_word_list(arg1: *mut ARRAY) -> *mut WORD_LIST;
+}
+extern "C" {
+ pub fn array_from_word_list(arg1: *mut WORD_LIST) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_keys_to_word_list(arg1: *mut ARRAY) -> *mut WORD_LIST;
+}
+extern "C" {
+ pub fn array_assign_list(arg1: *mut ARRAY, arg2: *mut WORD_LIST) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn array_to_argv(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_int,
+ ) -> *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_to_kvpair(
+ arg1: *mut ARRAY,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_to_assign(
+ arg1: *mut ARRAY,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_to_string(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: ::std::os::raw::c_int,
+ ) -> *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn array_from_string(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: *mut ::std::os::raw::c_char,
+ ) -> *mut ARRAY;
+}
+extern "C" {
+ pub fn execute_array_command(
+ arg1: *mut ARRAY,
+ arg2: *mut ::std::os::raw::c_void,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}trap_list"]
+ pub static mut trap_list: [*mut ::std::os::raw::c_char; 0usize];
+}
+extern "C" {
+ #[link_name = "\u{1}trapped_signal_received"]
+ pub static mut trapped_signal_received: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}wait_signal_received"]
+ pub static mut wait_signal_received: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}running_trap"]
+ pub static mut running_trap: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}trap_saved_exit_value"]
+ pub static mut trap_saved_exit_value: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}suppress_debug_trap_verbose"]
+ pub static mut suppress_debug_trap_verbose: ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn initialize_traps();
+}
+extern "C" {
+ pub fn run_pending_traps();
+}
+extern "C" {
+ pub fn queue_sigchld_trap(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn maybe_set_sigchld_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_impossible_sigchld_trap();
+}
+extern "C" {
+ pub fn set_sigchld_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_debug_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_error_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_return_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn maybe_set_debug_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn maybe_set_error_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn maybe_set_return_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_sigint_trap(arg1: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn set_signal(arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_char);
+}
+extern "C" {
+ pub fn restore_default_signal(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn ignore_signal(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn run_exit_trap() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn run_trap_cleanup(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn run_debug_trap() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn run_error_trap();
+}
+extern "C" {
+ pub fn run_return_trap();
+}
+extern "C" {
+ pub fn free_trap_strings();
+}
+extern "C" {
+ pub fn reset_signal_handlers();
+}
+extern "C" {
+ pub fn restore_original_signals();
+}
+extern "C" {
+ pub fn get_original_signal(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn run_interrupt_trap(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn maybe_call_trap_handler(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn signal_is_special(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn signal_is_trapped(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn signal_is_pending(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn signal_is_ignored(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn signal_is_hard_ignored(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn set_signal_hard_ignored(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn set_signal_ignored(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn signal_in_progress(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn set_trap_state(arg1: ::std::os::raw::c_int);
+}
+extern "C" {
+ pub fn next_pending_trap(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn first_pending_trap() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn clear_pending_traps();
+}
+extern "C" {
+ pub fn any_signals_trapped() -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn check_signals();
+}
+extern "C" {
+ pub fn check_signals_and_traps();
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct direct {
+ pub d_ino: ::std::os::raw::c_long,
+ pub d_reclen: ::std::os::raw::c_ushort,
+ pub d_namlen: ::std::os::raw::c_ushort,
+ pub d_name: [::std::os::raw::c_char; 16usize],
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct DIR {
+ pub dd_fd: ::std::os::raw::c_int,
+ pub dd_loc: ::std::os::raw::c_int,
+ pub dd_size: ::std::os::raw::c_int,
+ pub dd_buf: [::std::os::raw::c_char; 512usize],
+}
+extern "C" {
+ pub fn opendir() -> *mut DIR;
+}
+extern "C" {
+ pub fn readdir() -> *mut direct;
+}
+extern "C" {
+ pub fn telldir() -> ::std::os::raw::c_long;
+}
+extern "C" {
+ pub fn seekdir();
+}
+extern "C" {
+ pub fn closedir();
+}
+extern "C" {
+ pub fn glob_pattern_p(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn glob_vector(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: ::std::os::raw::c_int,
+ ) -> *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn glob_filename(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: ::std::os::raw::c_int,
+ ) -> *mut *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ pub fn extglob_pattern_p(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}glob_error_return"]
+ pub static mut glob_error_return: *mut ::std::os::raw::c_char;
+}
+extern "C" {
+ #[link_name = "\u{1}noglob_dot_filenames"]
+ pub static mut noglob_dot_filenames: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "\u{1}glob_ignore_case"]
+ pub static mut glob_ignore_case: ::std::os::raw::c_int;
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct _COLLSYM {
+ pub name: *mut ::std::os::raw::c_char,
+ pub code: ::std::os::raw::c_uchar,
+}
+pub type __COLLSYM = _COLLSYM;
+extern "C" {
+ #[link_name = "\u{1}POSIXCOLL"]
+ pub static mut POSIXCOLL: [__COLLSYM; 96usize];
+}
+extern "C" {
+ pub fn strmatch(
+ arg1: *mut ::std::os::raw::c_char,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+extern "C" {
+ pub fn wcsmatch(
+ arg1: *mut wchar_t,
+ arg2: *mut wchar_t,
+ arg3: ::std::os::raw::c_int,
+ ) -> ::std::os::raw::c_int;
+}
+pub type __builtin_va_list = [__va_list_tag; 1usize];
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __va_list_tag {
+ pub gp_offset: ::std::os::raw::c_uint,
+ pub fp_offset: ::std::os::raw::c_uint,
+ pub overflow_arg_area: *mut ::std::os::raw::c_void,
+ pub reg_save_area: *mut ::std::os::raw::c_void,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __locale_data {
+ pub _address: u8,
+}
diff --git a/bash-5.1/builtins_rust/history/src/lib.rs b/bash-5.1/builtins_rust/history/src/lib.rs
index acc108a465cbea4b72ab25e896da0e53071b5f76..e345fa806fa38c7ad9e361ac25ff8bc2a162fc2f 100644
--- a/bash-5.1/builtins_rust/history/src/lib.rs
+++ b/bash-5.1/builtins_rust/history/src/lib.rs
@@ -24,7 +24,7 @@ pub extern "C" fn r_history_builtin(mut list: *mut WordList) -> i32 {
let mut opt: c_int;
let mut result: c_int;
- let mut filename: *mut c_char;
+ let filename: *mut c_char;
let mut delete_arg: *mut c_char = PT_NULL as *mut c_char;
let mut range: *mut c_char;
@@ -206,7 +206,7 @@ fn histtime(hlist: *mut HIST_ENTRY, histtimefmt: *const c_char) -> *mut c_char
unsafe {
static mut timestr: [c_char;128] = [0;128];
- let mut t = history_get_time(hlist);
+ let t = history_get_time(hlist);
let tm = if t != 0 {libc::localtime(&t)} else {PT_NULL as *mut libc::tm};
if t != 0 && !tm.is_null() {
strftime(std::mem::transmute(×tr),
@@ -239,7 +239,7 @@ unsafe fn quit()
unsafe fn display_history(list: *mut WordList) -> c_int
{
let mut limit:c_long = 0;
- let mut histtimefmt: *mut c_char;
+ let histtimefmt: *mut c_char;
let mut timestr: *mut c_char;
if !list.is_null() {
@@ -317,7 +317,7 @@ fn expand_and_print_history(mut list: *mut WordList) -> c_int
{
unsafe {
- let mut s: *mut c_char = PT_NULL as *mut c_char;
+ let s: *mut c_char = PT_NULL as *mut c_char;
let mut result: c_int;
if hist_last_line_pushed == 0 && hist_last_line_added != 0 && bash_delete_last_history() == 0 {
diff --git a/bash-5.1/builtins_rust/jobs/build.rs b/bash-5.1/builtins_rust/jobs/build.rs
deleted file mode 100644
index 5b5544932086123d93bad082cc9783b5d85fd090..0000000000000000000000000000000000000000
--- a/bash-5.1/builtins_rust/jobs/build.rs
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
- use std::{env};
-
- fn main() {
-
- let library_dir = "/opt/rsbash/builtins";
-
- println!("cargo:rustc-link-search=native={}", env::join_paths(&[library_dir]).unwrap().to_str().unwrap());
-
- println!("cargo:rustc-flags=-l dylib=jobs");
- println!("cargo:rustc-flags=-l dylib=trap");
- println!("cargo:rustc-flags=-l dylib=execute_cmd");
- println!("cargo:rustc-flags=-l dylib=unwind_prot");
- println!("cargo:rustc-flags=-l dylib=flags");
- println!("cargo:rustc-flags=-l dylib=variables");
- println!("cargo:rustc-flags=-l dylib=builtins_break");
- println!("cargo:rustc-flags=-l dylib=builtins_common");
- println!("cargo:rustc-flags=-l dylib=sig");
- println!("cargo:rustc-flags=-l dylib=builtins_wait");
- println!("cargo:rustc-flags=-l dylib=shell");
- println!("cargo:rustc-flags=-l dylib=input");
- println!("cargo:rustc-flags=-l dylib=xmalloc");
- println!("cargo:rustc-flags=-l dylib=version");
- println!("cargo:rustc-flags=-l dylib=error");
- println!("cargo:rustc-flags=-l dylib=subst");
- println!("cargo:rustc-flags=-l dylib=lib_sh_winsize");
- println!("cargo:rustc-flags=-l dylib=dispose_cmd");
- println!("cargo:rustc-flags=-l dylib=lib_readline_readline");
- println!("cargo:rustc-flags=-l dylib=general");
- println!("cargo:rustc-flags=-l dylib=lib_sh_oslib");
- println!("cargo:rustc-flags=-l dylib=list");
- println!("cargo:rustc-flags=-l dylib=builtins_evalstring");
- println!("cargo:rustc-flags=-l dylib=y.tab");
- println!("cargo:rustc-flags=-l dylib=builtins_evalfile");
- println!("cargo:rustc-flags=-l dylib=lib_sh_casemod");
- println!("cargo:rustc-flags=-l dylib=lib_sh_fmtulong");
- println!("cargo:rustc-flags=-l dylib=builtins_set");
- println!("cargo:rustc-flags=-l dylib=lib_readline_history");
- println!("cargo:rustc-flags=-l dylib=mailcheck");
- println!("cargo:rustc-flags=-l dylib=bashhist");
- println!("cargo:rustc-flags=-l dylib=bashline");
- println!("cargo:rustc-flags=-l dylib=assoc");
- println!("cargo:rustc-flags=-l dylib=builtins_shopt");
- println!("cargo:rustc-flags=-l dylib=lib_readline_histfile");
- println!("cargo:rustc-flags=-l dylib=hashlib");
- println!("cargo:rustc-flags=-l dylib=print_cmd");
- println!("cargo:rustc-flags=-l dylib=copy_cmd");
- println!("cargo:rustc-flags=-l dylib=hashcmd");
- println!("cargo:rustc-flags=-l dylib=pathexp");
- println!("cargo:rustc-flags=-l dylib=lib_sh_random");
- println!("cargo:rustc-flags=-l dylib=findcmd");
- println!("cargo:rustc-flags=-l dylib=arrayfunc");
- println!("cargo:rustc-flags=-l dylib=lib_readline_terminal");
- println!("cargo:rustc-flags=-l dylib=array");
- println!("cargo:rustc-flags=-l dylib=lib_readline_complete");
- println!("cargo:rustc-flags=-l dylib=alias");
- println!("cargo:rustc-flags=-l dylib=builtins_getopt");
- println!("cargo:rustc-flags=-l dylib=locale");
- println!("cargo:rustc-flags=-l dylib=lib_readline_shell");
- println!("cargo:rustc-flags=-l dylib=lib_sh_stringvec");
- println!("cargo:rustc-flags=-l dylib=lib_sh_itos");
- println!("cargo:rustc-flags=-l dylib=pcomplete");
- println!("cargo:rustc-flags=-l dylib=lib_sh_strtrans");
- println!("cargo:rustc-flags=-l dylib=lib_readline_histexpand");
- println!("cargo:rustc-flags=-l dylib=lib_sh_shquote");
- println!("cargo:rustc-flags=-l dylib=builtins_pushd");
- println!("cargo:rustc-flags=-l dylib=redir");
- println!("cargo:rustc-flags=-l dylib=lib_sh_pathcanon");
- println!("cargo:rustc-flags=-l dylib=builtins_getopts");
- println!("cargo:rustc-flags=-l dylib=lib_readline_colors");
- println!("cargo:rustc-flags=-l dylib=lib_readline_mbutil");
- println!("cargo:rustc-flags=-l dylib=lib_readline_signals");
- println!("cargo:rustc-flags=-l dylib=lib_readline_text");
- println!("cargo:rustc-flags=-l dylib=lib_readline_parse-colors");
- println!("cargo:rustc-flags=-l dylib=lib_readline_display");
- println!("cargo:rustc-flags=-l dylib=lib_readline_util");
- println!("cargo:rustc-flags=-l dylib=lib_glob_xmbsrtowcs");
- println!("cargo:rustc-flags=-l dylib=lib_glob_gmisc");
- println!("cargo:rustc-flags=-l dylib=lib_sh_shmbchar");
- println!("cargo:rustc-flags=-l dylib=make_cmd");
- println!("cargo:rustc-flags=-l dylib=syntax");
- println!("cargo:rustc-flags=-l dylib=lib_glob_strmatch");
- println!("cargo:rustc-flags=-l dylib=lib_glob_glob");
- println!("cargo:rustc-flags=-l dylib=builtins_declare");
- println!("cargo:rustc-flags=-l dylib=stringlib");
- println!("cargo:rustc-flags=-l dylib=builtins_setattr");
- println!("cargo:rustc-flags=-l dylib=braces");
- println!("cargo:rustc-flags=-l dylib=lib_readline_misc");
- println!("cargo:rustc-flags=-l dylib=lib_readline_rltty");
- println!("cargo:rustc-flags=-l dylib=lib_readline_keymaps");
- println!("cargo:rustc-flags=-l dylib=lib_readline_kill");
- println!("cargo:rustc-flags=-l dylib=lib_readline_input");
- println!("cargo:rustc-flags=-l dylib=lib_readline_vi_mode");
- println!("cargo:rustc-flags=-l dylib=lib_readline_macro");
- println!("cargo:rustc-flags=-l dylib=lib_readline_bind");
- println!("cargo:rustc-flags=-l dylib=lib_readline_undo");
- println!("cargo:rustc-flags=-l dylib=lib_readline_funmap");
- println!("cargo:rustc-flags=-l dylib=lib_readline_nls");
- println!("cargo:rustc-flags=-l dylib=builtins_read");
- println!("cargo:rustc-flags=-l dylib=eval");
- println!("cargo:rustc-flags=-l dylib=lib_sh_setlinebuf");
- println!("cargo:rustc-flags=-l dylib=lib_sh_netconn");
- println!("cargo:rustc-flags=-l dylib=lib_sh_input_avail");
- println!("cargo:rustc-flags=-l dylib=lib_sh_shtty");
- println!("cargo:rustc-flags=-l dylib=lib_sh_zread");
- println!("cargo:rustc-flags=-l dylib=lib_sh_ufuncs");
- println!("cargo:rustc-flags=-l dylib=lib_sh_uconvert");
- println!("cargo:rustc-flags=-l dylib=pcomplib");
- println!("cargo:rustc-flags=-l dylib=bracecomp");
- println!("cargo:rustc-flags=-l dylib=lib_sh_spell");
- println!("cargo:rustc-flags=-l dylib=lib_sh_fnxform");
- println!("cargo:rustc-flags=-l dylib=lib_termcap_termcap");
- println!("cargo:rustc-flags=-l dylib=lib_termcap_tparam");
- println!("cargo:rustc-flags=-l dylib=builtins_bashgetopt");
- println!("cargo:rustc-flags=-l dylib=builtins_source");
- println!("cargo:rustc-flags=-l dylib=lib_sh_shmatch");
- println!("cargo:rustc-flags=-l dylib=test");
- println!("cargo:rustc-flags=-l dylib=builtins_return");
- println!("cargo:rustc-flags=-l dylib=builtins_exec");
- println!("cargo:rustc-flags=-l dylib=builtins_command");
- println!("cargo:rustc-flags=-l dylib=lib_sh_mbschr");
- println!("cargo:rustc-flags=-l dylib=expr");
- println!("cargo:rustc-flags=-l dylib=lib_sh_timeval");
- println!("cargo:rustc-flags=-l dylib=lib_sh_fpurge");
- println!("cargo:rustc-flags=-l dylib=builtins_fc");
- println!("cargo:rustc-flags=-l dylib=builtins_mapfile");
- println!("cargo:rustc-flags=-l dylib=builtins_eval");
- println!("cargo:rustc-flags=-l dylib=builtins_jobs");
- println!("cargo:rustc-flags=-l dylib=builtins_cd");
- println!("cargo:rustc-flags=-l dylib=builtins_shopt");
- println!("cargo:rustc-flags=-l dylib=builtins_echo");
- println!("cargo:rustc-flags=-l dylib=lib_glob_smatch");
- println!("cargo:rustc-flags=-l dylib=lib_sh_utf8");
- println!("cargo:rustc-flags=-l dylib=lib_readline_search");
- println!("cargo:rustc-flags=-l dylib=lib_readline_isearch");
- println!("cargo:rustc-flags=-l dylib=lib_sh_stringlist");
- println!("cargo:rustc-flags=-l dylib=builtins_complete");
- println!("cargo:rustc-flags=-l dylib=builtins_exit");
- println!("cargo:rustc-flags=-l dylib=lib_sh_tmpfile");
- println!("cargo:rustc-flags=-l dylib=lib_sh_netopen");
- println!("cargo:rustc-flags=-l dylib=lib_sh_eaccess");
- println!("cargo:rustc-flags=-l dylib=lib_readline_histsearch");
- println!("cargo:rustc-flags=-l dylib=lib_tilde_tilde");
- println!("cargo:rustc-flags=-l dylib=lib_sh_makepath");
- println!("cargo:rustc-flags=-l dylib=builtins_shift");
- println!("cargo:rustc-flags=-l dylib=lib_readline_parens");
- println!("cargo:rustc-flags=-l dylib=builtins_type");
- println!("cargo:rustc-flags=-l dylib=lib_sh_zmapfd");
- println!("cargo:rustc-flags=-l dylib=lib_sh_mailstat");
- println!("cargo:rustc-flags=-l dylib=builtins_builtins");
- println!("cargo:rustc-flags=-l dylib=builtins_kill");
- println!("cargo:rustc-flags=-l dylib=builtins_times");
- println!("cargo:rustc-flags=-l dylib=builtins_printf");
- println!("cargo:rustc-flags=-l dylib=builtins_umask");
- println!("cargo:rustc-flags=-l dylib=builtins_let");
- println!("cargo:rustc-flags=-l dylib=builtins_suspend");
- println!("cargo:rustc-flags=-l dylib=builtins_history");
- println!("cargo:rustc-flags=-l dylib=builtins_bind");
- println!("cargo:rustc-flags=-l dylib=builtins_fg_bg");
- println!("cargo:rustc-flags=-l dylib=builtins_builtin");
- println!("cargo:rustc-flags=-l dylib=builtins_alias");
- println!("cargo:rustc-flags=-l dylib=builtins_hash");
- println!("cargo:rustc-flags=-l dylib=builtins_enable");
- println!("cargo:rustc-flags=-l dylib=builtins_help");
- println!("cargo:rustc-flags=-l dylib=builtins_trap");
- println!("cargo:rustc-flags=-l dylib=builtins_caller");
- println!("cargo:rustc-flags=-l dylib=builtins_colon");
- println!("cargo:rustc-flags=-l dylib=builtins_ulimit");
- println!("cargo:rustc-flags=-l dylib=builtins_test");
- println!("cargo:rustc-flags=-l dylib=lib_sh_wcsnwidth");
- println!("cargo:rustc-flags=-l dylib=lib_readline_callback");
- println!("cargo:rustc-flags=-l dylib=lib_sh_zcatfd");
- println!("cargo:rustc-flags=-l dylib=lib_sh_zwrite");
- println!("cargo:rustc-flags=-l dylib=lib_sh_unicode");
- println!("cargo:rustc-flags=-l dylib=lib_sh_zgetline");
- println!("cargo:rustc-flags=-l dylib=lib_malloc_malloc");
- println!("cargo:rustc-flags=-l dylib=lib_sh_pathphys");
- println!("cargo:rustc-flags=-l dylib=lib_sh_fmtumax");
-
-
-
- }
diff --git a/bash-5.1/builtins_rust/jobs/src/lib.rs b/bash-5.1/builtins_rust/jobs/src/lib.rs
index cc0ee93fb01c9b312eefffa6584c82ebc12519a9..87b0577b85ced085aca5ba28d40aff2462aded6d 100644
--- a/bash-5.1/builtins_rust/jobs/src/lib.rs
+++ b/bash-5.1/builtins_rust/jobs/src/lib.rs
@@ -397,7 +397,7 @@ extern "C" {
l=(*l).next;
}
- let mut c_str_jobs_builtin = CString::new("jobs_builtin").unwrap();
+ let c_str_jobs_builtin = CString::new("jobs_builtin").unwrap();
/* Next make a new simple command and execute it. */
begin_unwind_frame (c_str_jobs_builtin.as_ptr() as * mut c_char);
@@ -433,7 +433,7 @@ pub extern "C" fn r_jobs_builtin(mut list:*mut WordList)->i32 {
unsafe {
reset_internal_getopt();
- let mut c_str_lpnxrs = CString::new("lpnxrs").unwrap(); // from a &str, creates a new allocation
+ let c_str_lpnxrs = CString::new("lpnxrs").unwrap(); // from a &str, creates a new allocation
opt = internal_getopt (list, c_str_lpnxrs.as_ptr() as * mut c_char);
while opt != -1 {
@@ -444,7 +444,7 @@ pub extern "C" fn r_jobs_builtin(mut list:*mut WordList)->i32 {
'n'=>{form = JLIST_CHANGED_ONLY!();}
'x'=>{
if form != JLIST_STANDARD!() {
- let mut c_str_err = CString::new("no other options allowed with `-x'").unwrap(); // from a &str, creates a new allocation
+ let c_str_err = CString::new("no other options allowed with `-x'").unwrap(); // from a &str, creates a new allocation
builtin_error (c_str_err.as_ptr());
return EXECUTION_FAILURE!();
}
@@ -519,7 +519,7 @@ pub extern "C" fn r_disown_builtin (list:* mut WordList)->libc::c_int {
let mut pid_value:c_long=0;
unsafe {
reset_internal_getopt ();
- let mut c_str_ahr = CString::new("ahr").unwrap(); // from a &str, creates a new allocation
+ let c_str_ahr = CString::new("ahr").unwrap(); // from a &str, creates a new allocation
opt = internal_getopt (list, c_str_ahr.as_ptr() as * mut c_char);
while opt != -1 {
let opt_char:char= opt as u8 as char;
@@ -551,7 +551,7 @@ pub extern "C" fn r_disown_builtin (list:* mut WordList)->libc::c_int {
return EXECUTION_SUCCESS!();
}
BLOCK_CHILD !(Some(&mut set), Some(&mut oset));
- if (loptend !=std::ptr::null_mut() && legal_number ((*(*loptend).word).word, &mut pid_value) !=0 && pid_value == pid_value) {
+ if loptend !=std::ptr::null_mut() && legal_number ((*(*loptend).word).word, &mut pid_value) !=0 && pid_value == pid_value {
job=get_job_by_pid ( pid_value as i32, 0, 0 as *mut*mut PROCESS);
}else {
job = get_job_spec (loptend);
diff --git a/bash-5.1/builtins_rust/printf/src/lib.rs b/bash-5.1/builtins_rust/printf/src/lib.rs
index c6a9c6c839acd2d5a46dd5b67ba484524a4e3ca8..31c0cf5447ee09c16bde0303a652d9201e9b9e48 100644
--- a/bash-5.1/builtins_rust/printf/src/lib.rs
+++ b/bash-5.1/builtins_rust/printf/src/lib.rs
@@ -1,7 +1,7 @@
//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use std::ffi::CStr;
+
use std::{ffi::CString};
use libc::{size_t, c_int, c_uint, c_char, c_long, c_void, PT_NULL, c_ulong, strchr, };
@@ -186,8 +186,8 @@ unsafe {
if *fmt == b'\\' as c_char {
fmt = (fmt as usize + 1) as *mut c_char;
- let mut mbch: [libc::c_char;25] = [0; 25];
- let mut mblen: c_int = 0;
+ let mbch: [libc::c_char;25] = [0; 25];
+ let mblen: c_int = 0;
fmt = (fmt as usize + tescape(fmt, mbch.as_ptr() as *mut c_char, std::mem::transmute(&mblen), PT_NULL as *mut c_int) as usize) as *mut c_char;
let mut mbind = 0;
@@ -502,7 +502,7 @@ unsafe {
}
}
b'b' => {
- let mut rlen: c_int = 0;
+ let rlen: c_int = 0;
let mut r: c_int = 0;
ch = 0;
let p = getstr();
@@ -999,9 +999,9 @@ unsafe fn tescape(estart: *mut c_char, cp:*mut c_char, lenp: *mut c_int, sawc: *
unsafe fn bexpand(string: *mut c_char, len: c_int, sawc: *mut c_int, lenp: *mut c_int) -> *mut c_char
{
let mut mbch:[c_char; 25];
- let mut mblen: c_int = 0;
+ let mblen: c_int = 0;
- let mut ret: *mut c_char;
+ let ret: *mut c_char;
let mut r: *mut c_char;
let mut s: *mut c_char;
let mut c: c_char;
@@ -1030,7 +1030,7 @@ unsafe fn bexpand(string: *mut c_char, len: c_int, sawc: *mut c_int, lenp: *mut
continue;
}
- let mut temp: c_int = 0;
+ let temp: c_int = 0;
mbch = [0; 25];
let n = tescape(s, mbch.as_mut_ptr() as *mut c_char,
std::mem::transmute(&mblen), std::mem::transmute(&temp));
@@ -1154,7 +1154,7 @@ unsafe fn getintmax() -> c_long
return asciicode();
}
- let mut ep: *mut c_char = PT_NULL as *mut c_char;
+ let ep: *mut c_char = PT_NULL as *mut c_char;
*libc::__errno_location() = 0;
let ret = libc::strtol((*(*garglist).word).word, std::mem::transmute(&ep), 0);
if *ep != 0 {
@@ -1179,7 +1179,7 @@ unsafe fn getuintmax() -> c_ulong
}
*libc::__errno_location() = 0;
- let mut ep: *mut c_char = PT_NULL as *mut c_char;
+ let ep: *mut c_char = PT_NULL as *mut c_char;
let ret = libc::strtoul((*(*garglist).word).word, std::mem::transmute(&ep), 0);
if *ep != 0 {
sh_invalidnum((*(*garglist).word).word);
diff --git a/bash-5.1/builtins_rust/pushd/src/lib.rs b/bash-5.1/builtins_rust/pushd/src/lib.rs
index f3caec293bdd52f869f371dedb22c881731250f6..48cd8d5dc14c08165a5d4eab0299b55fb8bef8e8 100644
--- a/bash-5.1/builtins_rust/pushd/src/lib.rs
+++ b/bash-5.1/builtins_rust/pushd/src/lib.rs
@@ -1,123 +1,149 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
-use libc::{c_char, c_long, c_void};
-use std::{ffi::{CString,CStr}};
+use libc::{c_char, c_void};
+use std::ffi::CString;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage, r_savestring};
+use rcommon::{r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:libc::c_int,
- rflags:libc::c_int,
- flags:libc::c_int,
- instruction:r_instruction,
- redirectee:libc::c_int,
- here_doc_eof:*mut c_char
+ next: *mut REDIRECT,
+ redirector: libc::c_int,
+ rflags: libc::c_int,
+ flags: libc::c_int,
+ instruction: r_instruction,
+ redirectee: libc::c_int,
+ here_doc_eof: *mut c_char,
}
/* FOR command. */
#[repr(C)]
pub struct for_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:libc::c_int
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: libc::c_int,
}
#[repr(C)]
pub struct case_com {
- flags:libc::c_int,
- line:libc::c_int,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ flags: libc::c_int,
+ line: libc::c_int,
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct while_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore:libc::c_int,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector:libc::c_int
+ ignore: libc::c_int,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: libc::c_int,
}
#[repr(C)]
pub struct simple_com {
- flags:libc::c_int,
- line:libc::c_int,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: libc::c_int,
+ line: libc::c_int,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut c_char
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct group_com {
- ignore:libc::c_int,
- command:*mut COMMAND,
- source_file:*mut c_char
+ ignore: libc::c_int,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct select_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
@@ -186,33 +212,32 @@ pub struct COMMAND {
value:VALUE_COMMAND
}
-
#[macro_export]
macro_rules! NOCD {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
macro_rules! ROTATE {
- () => {
- 0x02
- }
+ () => {
+ 0x02
+ };
}
#[macro_export]
macro_rules! LONGFORM {
- () => {
- 0x04
- }
+ () => {
+ 0x04
+ };
}
#[macro_export]
macro_rules! CLEARSTAK {
- () => {
- 0x08
- }
+ () => {
+ 0x08
+ };
}
extern "C" {
@@ -469,7 +494,7 @@ while list != std::ptr::null_mut() {
direction = *((*((*list).word)).word);
if direction == '+' as c_char || direction == '-' as c_char {
- if legal_number ((((*((*list).word)).word as usize + 1) as * mut c_char), & mut which) == 0 {
+ if legal_number (((*((*list).word)).word as usize + 1) as * mut c_char, & mut which) == 0 {
sh_invalidnum ((*((*list).word)).word);
builtin_usage ();
return EX_USAGE;
@@ -850,7 +875,7 @@ pub extern "C" fn r_get_dirstack_from_string (strt:* mut c_char)-> * mut c_char
#[no_mangle]
pub extern "C" fn r_get_dirstack_element (ind:libc::c_long, sign:i32)-> * mut c_char
{
- let mut i:i32;
+ let i:i32;
unsafe {
i = r_get_dirstack_index (ind, sign, std::ptr::null_mut());
if i < 0 || i > directory_list_offset {
diff --git a/bash-5.1/builtins_rust/pushed/Cargo.toml b/bash-5.1/builtins_rust/pushed/Cargo.toml
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/bash-5.1/builtins_rust/pushed/src/lib.rs b/bash-5.1/builtins_rust/pushed/src/lib.rs
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/bash-5.1/builtins_rust/read/src/intercdep.rs b/bash-5.1/builtins_rust/read/src/intercdep.rs
index fd31529edbd535251e76bc403beac2411662e34e..7f9cbcd69193899db870730890b9ad6df4319ced 100644
--- a/bash-5.1/builtins_rust/read/src/intercdep.rs
+++ b/bash-5.1/builtins_rust/read/src/intercdep.rs
@@ -1,7 +1,7 @@
//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use rcommon::{r_builtin_usage,r_sh_invalidid,r_builtin_bind_variable,WordList,WordDesc};
+use rcommon::{r_builtin_usage,r_sh_invalidid,r_builtin_bind_variable,WordList};
pub type SHELL_VAR = rcommon::SHELL_VAR;
use rhelp::r_builtin_help;
pub type __intmax_t = c_long;
diff --git a/bash-5.1/builtins_rust/read/src/lib.rs b/bash-5.1/builtins_rust/read/src/lib.rs
index 627d34a2debca4da5322942a3c729d0a6ef2c0d8..3b9142e963890e904b5b7aad0207d287fe7128c5 100644
--- a/bash-5.1/builtins_rust/read/src/lib.rs
+++ b/bash-5.1/builtins_rust/read/src/lib.rs
@@ -1,826 +1,901 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char, c_long, c_ulong, c_uint, size_t, c_void, PT_NULL, ssize_t};
+use libc::{c_char, c_int, c_long, c_uint, c_ulong, c_void, size_t, ssize_t, PT_NULL};
use nix::errno::errno;
-use std::{ffi::{CString, CStr}, ptr::null_mut,};
-//use rcommon::{r_builtin_usage,r_sh_invalidid,r_builtin_bind_variable,SHELL_VAR};
+use std::{
+ ffi::{CStr, CString},
+ ptr::null_mut,
+};
include!(concat!("intercdep.rs"));
#[no_mangle]
-pub static mut alrmbuf:sigjmp_buf = [__jmp_buf_tag{
- __jmpbuf:[0;8],
- __mask_was_saved:0,
- __saved_mask:__sigset_t{__val:[0;16]},
-};1];
+pub static mut alrmbuf: sigjmp_buf = [__jmp_buf_tag {
+ __jmpbuf: [0; 8],
+ __mask_was_saved: 0,
+ __saved_mask: __sigset_t { __val: [0; 16] },
+}; 1];
-static mut old_alrm : *mut SigHandler = PT_NULL as *mut SigHandler;
+static mut old_alrm: *mut SigHandler = PT_NULL as *mut SigHandler;
-// static mut sigalrm_seen : c_int = 0;
-static mut reading : c_int = 0;
-static mut tty_modified : c_int = 0;
+static mut reading: c_int = 0;
+static mut tty_modified: c_int = 0;
-static mut delim : c_char= b'\n' as c_char;
+static mut delim: c_char = b'\n' as c_char;
#[derive(Clone, Copy)]
pub struct tty_save {
fd: i32,
attrs: libc::termios,
}
-// static mut termsave : Option = None;
-static mut termsave:tty_save = tty_save{
- fd:0,
- attrs:libc::termios {
- c_iflag: (0),
- c_oflag: (0),
- c_cflag: (0),
- c_lflag: (0),
- c_line: (0),
- c_cc: [0;32],
- c_ispeed: (0),
- c_ospeed: (0)
- }
+static mut termsave: tty_save = tty_save {
+ fd: 0,
+ attrs: libc::termios {
+ c_iflag: (0),
+ c_oflag: (0),
+ c_cflag: (0),
+ c_lflag: (0),
+ c_line: (0),
+ c_cc: [0; 32],
+ c_ispeed: (0),
+ c_ospeed: (0),
+ },
};
-static mut interactive : c_int = 0;
-static mut default_buffered_input : c_int = -1;
-
+static mut interactive: c_int = 0;
+static mut default_buffered_input: c_int = -1;
#[no_mangle]
pub extern "C" fn r_read_builtin(mut list: *mut WordList) -> i32 {
-
- let mut varname :*mut c_char = libc::PT_NULL as *mut c_char;
- let mut size : c_int = 0;
- let mut nr : c_int = 0;
- let mut pass_next : c_int = 0;
- let mut saw_escape : c_int = 0;
- let mut eof : c_int;
- let mut opt : c_int;
- let mut retval : c_int;
- let mut code : c_int;
- let mut print_ps2 : c_int;
- let mut nflag : c_int = 0;
-
- let mut i : c_int = 0;
-
- let mut input_is_tty : c_int = 0;
- let mut input_is_pipe : c_int = 0;
- let mut unbuffered_read : c_int = 0;
- let mut skip_ctlesc : c_int;
- let mut skip_ctlnul : c_int;
-
- let mut raw : c_int = 0;
- let mut edit : c_int = 0;
- let mut nchars : c_int = 0;
- let mut silent : c_int = 0;
- let mut have_timeout : c_int = 0;
- let mut ignore_delim : c_int = 0;
- let mut fd : c_int = 0;
-
- let mut lastsig : c_int = 0;
- let mut t_errno : c_int;
-
- let mut mb_cur_max : c_int;
-
- let mut tmsec : c_uint = 0;
- let mut tmusec : c_uint = 0;
-
- let mut ival : c_long = 0;
- let mut uval : c_long = 0;
- let mut intval : c_long = 0;
-
- let mut c : c_char = 0;
-
- let mut input_string : *mut c_char;
- let mut orig_input_string : *mut c_char;
+ let mut varname: *mut c_char = libc::PT_NULL as *mut c_char;
+ let mut size: c_int = 0;
+ let mut nr: c_int = 0;
+ let mut pass_next: c_int = 0;
+ let mut saw_escape: c_int = 0;
+ let mut eof: c_int;
+ let mut opt: c_int;
+ let mut retval: c_int;
+ let mut code: c_int;
+ let mut print_ps2: c_int;
+ let mut nflag: c_int = 0;
+
+ let mut i: c_int = 0;
+
+ let mut input_is_tty: c_int = 0;
+ let mut input_is_pipe: c_int = 0;
+ let mut unbuffered_read: c_int = 0;
+ let mut skip_ctlesc: c_int;
+ let mut skip_ctlnul: c_int;
+
+ let mut raw: c_int = 0;
+ let mut edit: c_int = 0;
+ let mut nchars: c_int = 0;
+ let mut silent: c_int = 0;
+ let mut have_timeout: c_int = 0;
+ let mut ignore_delim: c_int = 0;
+ let mut fd: c_int = 0;
+
+ let mut lastsig: c_int = 0;
+ let t_errno: c_int;
+
+ let mut _mb_cur_max: c_int;
+
+ let mut tmsec: c_uint = 0;
+ let mut tmusec: c_uint = 0;
+
+ let mut ival: c_long = 0;
+ let mut uval: c_long = 0;
+ let mut intval: c_long = 0;
+
+ let mut c: c_char = 0;
+
+ let mut input_string: *mut c_char;
+ let mut orig_input_string: *mut c_char;
let ifs_chars_null = CString::new("").unwrap();
- let mut ifs_chars : *mut c_char;
- let mut prompt : *mut c_char = PT_NULL as *mut c_char;
- let mut arrayname : *mut c_char = PT_NULL as *mut c_char;
+ let mut ifs_chars: *mut c_char;
+ let mut prompt: *mut c_char = PT_NULL as *mut c_char;
+ let mut arrayname: *mut c_char = PT_NULL as *mut c_char;
- let mut e : *mut c_char;
- let t : *mut c_char;
- let t1 : *mut c_char;
- let mut ps2 : *mut c_char;
- let mut tofree : *mut c_char;
+ let mut e: *mut c_char;
+ let t: *mut c_char;
+ let t1: *mut c_char;
+ let mut ps2: *mut c_char;
+ let mut tofree: *mut c_char;
- let mut tsb : libc::stat;
+ let mut tsb: libc::stat;
- let mut var : *mut SHELL_VAR = PT_NULL as *mut SHELL_VAR;
+ let mut var: *mut SHELL_VAR = PT_NULL as *mut SHELL_VAR;
- let mut ttattrs : libc::termios;
- let mut ttset : libc::termios;
+ let mut ttattrs: libc::termios;
+ let mut ttset: libc::termios;
unsafe {
ttattrs = std::mem::zeroed();
ttset = std::mem::zeroed();
}
- let mut alist : *mut WordList;
-
- let mut vflags : c_int;
- let mut rlbuf : *mut c_char = null_mut();
- let mut itext : *mut c_char = null_mut();
-
- let mut rlind : c_int = 0;
+ let alist: *mut WordList;
+ let vflags: c_int;
+ let mut rlbuf: *mut c_char = null_mut();
+ let mut itext: *mut c_char = null_mut();
- let mut save_instream : *mut libc::FILE;
+ let mut rlind: c_int = 0;
- let mut mb_cur_max : c_int = 1;
+ let mut save_instream: *mut libc::FILE;
-unsafe {
+ let mut mb_cur_max: c_int = 1;
- // if termsave.is_none() {
- // let tmp: tty_save = std::mem::zeroed();
- // termsave = Some(tmp);
- // }
- // ptermsave = std::mem::transmute(&termsave.unwrap());
-
- reset_internal_getopt();
- let opt_str = CString::new("ersa:d:i:n:p:t:u:N:").unwrap();
- opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- while opt != -1 {
- let opt_char:char=char::from(opt as u8);
- match opt_char {
- 'r' => raw = 1,
- 'p' => prompt = list_optarg,
- 's' => silent = 1,
- 'e' => edit = 1,
- 'i' => itext = list_optarg,
- 'a' => arrayname = list_optarg,
- 't' => {
- code = uconvert(list_optarg, &mut ival, &mut uval, PT_NULL as *mut *mut c_char);
- if code == 0 || ival < 0 || uval < 0 {
- let c_err = CString::new("%s: invalid timeout specification").unwrap();
- builtin_error( c_err.as_ptr(), list_optarg);
- return EXECUTION_FAILURE;
- } else {
- have_timeout = 1;
- tmsec = ival as c_uint;
- tmusec = uval as c_uint;
- }
- }
- 'N' | 'n' => {
- if opt_char == 'N' {
- ignore_delim = 1;
- delim = 255 as u8 as libc::c_char;
- }
- nflag = 1;
- code = legal_number(list_optarg, &mut intval);
- if code == 0 || intval < 0 || intval != (intval as c_int) as c_long {
- sh_invalidnum(list_optarg);
- return EXECUTION_FAILURE;
- } else {
- nchars = intval as c_int;
+ unsafe {
+ reset_internal_getopt();
+ let opt_str = CString::new("ersa:d:i:n:p:t:u:N:").unwrap();
+ opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
+ while opt != -1 {
+ let opt_char: char = char::from(opt as u8);
+ match opt_char {
+ 'r' => raw = 1,
+ 'p' => prompt = list_optarg,
+ 's' => silent = 1,
+ 'e' => edit = 1,
+ 'i' => itext = list_optarg,
+ 'a' => arrayname = list_optarg,
+ 't' => {
+ code = uconvert(
+ list_optarg,
+ &mut ival,
+ &mut uval,
+ PT_NULL as *mut *mut c_char,
+ );
+ if code == 0 || ival < 0 || uval < 0 {
+ let c_err = CString::new("%s: invalid timeout specification").unwrap();
+ builtin_error(c_err.as_ptr(), list_optarg);
+ return EXECUTION_FAILURE;
+ } else {
+ have_timeout = 1;
+ tmsec = ival as c_uint;
+ tmusec = uval as c_uint;
+ }
}
- }
- 'u' => {
- code = legal_number(list_optarg, &mut intval);
- if code == 0 || intval < 0 || intval != (intval as c_int) as c_long {
- let c_err = CString::new("%s: invalid file descriptor specification").unwrap();
- builtin_error(c_err.as_ptr(), list_optarg);
- return EXECUTION_FAILURE;
- } else {
- fd = intval as c_int;
+ 'N' | 'n' => {
+ if opt_char == 'N' {
+ ignore_delim = 1;
+ delim = 255 as u8 as libc::c_char;
+ }
+ nflag = 1;
+ code = legal_number(list_optarg, &mut intval);
+ if code == 0 || intval < 0 || intval != (intval as c_int) as c_long {
+ sh_invalidnum(list_optarg);
+ return EXECUTION_FAILURE;
+ } else {
+ nchars = intval as c_int;
+ }
}
- if sh_validfd(fd) == 0 {
- let c_err = CString::new("%d: invalid file descriptor: %s").unwrap();
- builtin_error(c_err.as_ptr(), fd, libc::strerror(nix::errno::errno()));
- return EXECUTION_FAILURE;
+ 'u' => {
+ code = legal_number(list_optarg, &mut intval);
+ if code == 0 || intval < 0 || intval != (intval as c_int) as c_long {
+ let c_err =
+ CString::new("%s: invalid file descriptor specification").unwrap();
+ builtin_error(c_err.as_ptr(), list_optarg);
+ return EXECUTION_FAILURE;
+ } else {
+ fd = intval as c_int;
+ }
+ if sh_validfd(fd) == 0 {
+ let c_err = CString::new("%d: invalid file descriptor: %s").unwrap();
+ builtin_error(c_err.as_ptr(), fd, libc::strerror(nix::errno::errno()));
+ return EXECUTION_FAILURE;
+ }
}
- }
- 'd' => {
+ 'd' => {
delim = *list_optarg;
}
-
- _ => {
- if opt == -99 {
- r_builtin_help();
+
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ r_builtin_usage();
return EX_USAGE;
}
- r_builtin_usage ();
- return EX_USAGE;
}
+ opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
}
- opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- }
- list = loptend;
+ list = loptend;
- //-t
- if have_timeout != 0 && tmsec == 0 && tmusec == 0 {
- return if input_avail(fd) != 0 {EXECUTION_SUCCESS} else {EXECUTION_FAILURE};
- }
+ //-t
+ if have_timeout != 0 && tmsec == 0 && tmusec == 0 {
+ return if input_avail(fd) != 0 {
+ EXECUTION_SUCCESS
+ } else {
+ EXECUTION_FAILURE
+ };
+ }
- vflags = if assoc_expand_once != 0 {(VA_NOEXPAND | VA_ONEWORD) as c_int} else {0};
- if !list.is_null() &&
- legal_identifier((*(*list).word).word) == 0 &&
- valid_array_reference((*(*list).word).word, vflags) == 0 {
+ vflags = if assoc_expand_once != 0 {
+ (VA_NOEXPAND | VA_ONEWORD) as c_int
+ } else {
+ 0
+ };
+ if !list.is_null()
+ && legal_identifier((*(*list).word).word) == 0
+ && valid_array_reference((*(*list).word).word, vflags) == 0
+ {
// sh_invalidid((*(*list).word).word);
r_sh_invalidid((*(*list).word).word);
return EXECUTION_FAILURE;
- }
-
- //忽略界定符
- if ignore_delim != 0{ //-N ignore_delim = 1
- delim = 255 as u8 as libc::c_char;
- }
-
- ifs_chars = getifs(); //ifs_chars is "\n"
- if ifs_chars.is_null() {
- ifs_chars = ifs_chars_null.as_ptr() as *mut c_char;
- }
-
- if ignore_delim != 0 {
- ifs_chars = ifs_chars_null.as_ptr() as *mut c_char;
- }
-
- skip_ctlesc = 0;
- skip_ctlnul = 0;
- e = ifs_chars;
-
- loop {
- if *e == 0 {
- break;
}
- skip_ctlesc |= (*e == 1) as c_int;
- skip_ctlnul |= (*e == 117) as c_int;
- e = ((e as usize) + 1) as *mut c_char;
- }
-
- input_string = xmalloc(112) as *mut c_char;
- *input_string = b'\0' as c_char;
-'out_assig_vars: loop {
- if nflag == 1 && nchars == 0 {
- let mut gc : c_int = 0;
- retval = libc::read(fd, &mut gc as *mut i32 as *mut c_void, 0) as c_int;
- retval = if retval >= 0 {EXECUTION_SUCCESS} else {EXECUTION_FAILURE};
-
- break 'out_assig_vars;
- }
+ //忽略界定符
+ if ignore_delim != 0 {
+ //-N ignore_delim = 1
+ delim = 255 as u8 as libc::c_char;
+ }
- //设置TMOUT后,TMOUT是默认读取时间
- let str_val = CString::new("TMOUT").unwrap();
- e = get_string_value(str_val.as_ptr());
- if have_timeout == 0 && !e.is_null() {
- code = uconvert(e, &mut ival, &mut uval, 0 as *mut *mut c_char);
- if code == 0 || ival < 0 || uval < 0 {
- tmsec = 0;
- tmusec = 0;
- } else {
- tmsec = ival as c_uint;
- tmusec = uval as c_uint;
+ ifs_chars = getifs(); //ifs_chars is "\n"
+ if ifs_chars.is_null() {
+ ifs_chars = ifs_chars_null.as_ptr() as *mut c_char;
}
- }
- let frame_name = CString::new("r_read_builtin").unwrap(); //有没有可能是r_read_builtin?
- begin_unwind_frame(frame_name.as_ptr() as *mut c_char);
+ if ignore_delim != 0 {
+ ifs_chars = ifs_chars_null.as_ptr() as *mut c_char;
+ }
-
- if interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input(fd) != 0 {
- sync_buffered_stream(default_buffered_input);
- }
+ skip_ctlesc = 0;
+ skip_ctlnul = 0;
+ e = ifs_chars;
- input_is_tty = libc::isatty(fd);
- if input_is_tty == 0 {
- input_is_pipe = (libc::lseek(fd, 0, libc::SEEK_CUR) < 0 && (errno() == libc::ESPIPE)) as c_int;
- }
-
- //如果设置 -p,-e,-s但输入不是终端,忽略
- if (!prompt.is_null() || edit != 0 || silent != 0) && input_is_tty == 0 {
- itext = PT_NULL as *mut c_char;
- edit = 0;
- silent = 0;
- }
+ loop {
+ if *e == 0 {
+ break;
+ }
+ skip_ctlesc |= (*e == 1) as c_int;
+ skip_ctlnul |= (*e == 117) as c_int;
+ e = ((e as usize) + 1) as *mut c_char;
+ }
- if edit != 0 {
- add_unwind_protect(xfree as *mut c_void, rlbuf);
- }
+ input_string = xmalloc(112) as *mut c_char;
+ *input_string = b'\0' as c_char;
- tsb = std::mem::zeroed();
- if tmsec > 0 || tmusec > 0 {
- if (libc::fstat(fd, &mut tsb as *mut libc::stat) < 0) ||
- ((tsb.st_mode & __S_IFMT) == __S_IFREG) {
- tmsec = 0;
- tmusec = 0;
- }
- }
+ 'out_assig_vars: loop {
+ if nflag == 1 && nchars == 0 {
+ let mut gc: c_int = 0;
+ retval = libc::read(fd, &mut gc as *mut i32 as *mut c_void, 0) as c_int;
+ retval = if retval >= 0 {
+ EXECUTION_SUCCESS
+ } else {
+ EXECUTION_FAILURE
+ };
- if tmsec > 0 || tmusec > 0 {
- code = __sigsetjmp(&mut alrmbuf as *mut __jmp_buf_tag, 0);
- if code != 0 {
- sigalrm_seen = 0;
- orig_input_string = PT_NULL as *mut c_char;
- *input_string.offset(i as isize) = b'\0' as c_char;
- if i == 0 {
- t = libc::malloc(1) as *mut c_char;
- *t = b'\0' as c_char;
- } else {
- t = libc::strcpy( xmalloc(
- (libc::strlen(input_string) + 1) as size_t) as *mut c_char, input_string);
+ break 'out_assig_vars;
}
- run_unwind_frame(frame_name.as_ptr() as *mut c_char);
- input_string = t;
- retval = 128 + libc::SIGALRM;
- break 'out_assig_vars;
- }
-
- if interactive_shell == 0 {
- initialize_terminating_signals();
- }
- old_alrm = set_signal_handler(libc::SIGALRM, sigalrm as *mut SigHandler);
- add_unwind_protect(reset_alarm as *mut c_void, PT_NULL as *mut c_char);
+ //设置TMOUT后,TMOUT是默认读取时间
+ let str_val = CString::new("TMOUT").unwrap();
+ e = get_string_value(str_val.as_ptr());
+ if have_timeout == 0 && !e.is_null() {
+ code = uconvert(e, &mut ival, &mut uval, 0 as *mut *mut c_char);
+ if code == 0 || ival < 0 || uval < 0 {
+ tmsec = 0;
+ tmusec = 0;
+ } else {
+ tmsec = ival as c_uint;
+ tmusec = uval as c_uint;
+ }
+ }
- if edit != 0 {
- add_unwind_protect(reset_attempted_completion_function as *mut c_void,
- PT_NULL as *mut c_char);
- add_unwind_protect(bashline_reset_event_hook as *mut c_void,
- PT_NULL as *mut c_char);
- }
- falarm(tmsec, tmusec);
- }
+ let frame_name = CString::new("r_read_builtin").unwrap(); //有没有可能是r_read_builtin?
+ begin_unwind_frame(frame_name.as_ptr() as *mut c_char);
- if nchars > 0 || delim != b'\n' as c_char { //-d -n
- if edit != 0 {
- if nchars > 0 {
- unwind_protect_mem(&mut rl_num_chars_to_read as *mut c_int, std::mem::size_of_val(&rl_num_chars_to_read) as c_int);
- rl_num_chars_to_read = nchars;
+ if interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input(fd) != 0 {
+ sync_buffered_stream(default_buffered_input);
}
- if delim != b'\n' as c_char {
- set_eol_delim(delim as c_int);
- add_unwind_protect(reset_eol_delim as *mut c_void, PT_NULL as *mut c_char);
+ input_is_tty = libc::isatty(fd);
+ if input_is_tty == 0 {
+ input_is_pipe =
+ (libc::lseek(fd, 0, libc::SEEK_CUR) < 0 && (errno() == libc::ESPIPE)) as c_int;
}
- } else if input_is_tty != 0 { //-d -n
- // termsave.unwrap().fd = fd;
- termsave.fd = fd;
- ttgetattr(fd, &mut ttattrs as *mut libc::termios);
- // termsave.unwrap().attrs = ttattrs;
- termsave.attrs = ttattrs;
-
- ttset = ttattrs;
- if silent != 0 {
- i = ttfd_cbreak(fd, std::mem::transmute(&ttset));
- } else {
- i = ttfd_onechar(fd, std::mem::transmute(&ttset));
+
+ //如果设置 -p,-e,-s但输入不是终端,忽略
+ if (!prompt.is_null() || edit != 0 || silent != 0) && input_is_tty == 0 {
+ itext = PT_NULL as *mut c_char;
+ edit = 0;
+ silent = 0;
}
- if i < 0 {
- sh_ttyerror(1);
+ if edit != 0 {
+ add_unwind_protect(xfree as *mut c_void, rlbuf);
}
- tty_modified = 1;
- // add_unwind_protect(ttyrestore as *mut c_void, ptermsave);
- add_unwind_protect(ttyrestore as *mut c_void, &mut termsave);
- if interactive_shell == 0 {
- initialize_terminating_signals();
+
+ tsb = std::mem::zeroed();
+ if tmsec > 0 || tmusec > 0 {
+ if (libc::fstat(fd, &mut tsb as *mut libc::stat) < 0)
+ || ((tsb.st_mode & __S_IFMT) == __S_IFREG)
+ {
+ tmsec = 0;
+ tmusec = 0;
+ }
}
- }
- } else if silent != 0 { //-s
- // termsave.unwrap().fd = fd;
- termsave.fd = fd;
- ttgetattr(fd, &mut ttattrs as *mut libc::termios);
- // termsave.unwrap().attrs = ttattrs;
- termsave.attrs = ttattrs;
-
- ttset = ttattrs;
- i = ttfd_noecho(fd, std::mem::transmute(&ttset));
- if i < 0 {
- sh_ttyerror(1);
- }
+ if tmsec > 0 || tmusec > 0 {
+ code = __sigsetjmp(&mut alrmbuf as *mut __jmp_buf_tag, 0);
+ if code != 0 {
+ sigalrm_seen = 0;
+ orig_input_string = PT_NULL as *mut c_char;
+ *input_string.offset(i as isize) = b'\0' as c_char;
+ if i == 0 {
+ t = libc::malloc(1) as *mut c_char;
+ *t = b'\0' as c_char;
+ } else {
+ t = libc::strcpy(
+ xmalloc((libc::strlen(input_string) + 1) as size_t) as *mut c_char,
+ input_string,
+ );
+ }
+ run_unwind_frame(frame_name.as_ptr() as *mut c_char);
+ input_string = t;
+ retval = 128 + libc::SIGALRM;
+ break 'out_assig_vars;
+ }
- tty_modified = 1;
- // add_unwind_protect(ttyrestore as *mut c_void, ptermsave);
- add_unwind_protect(ttyrestore as *mut c_void, &mut termsave );
- if interactive_shell == 0 {
- initialize_terminating_signals();
- }
- }
+ if interactive_shell == 0 {
+ initialize_terminating_signals();
+ }
- save_instream = std::mem::zeroed();
- if edit != 0 && fd != 0 {
+ old_alrm = set_signal_handler(libc::SIGALRM, sigalrm as *mut SigHandler);
+ add_unwind_protect(reset_alarm as *mut c_void, PT_NULL as *mut c_char);
+
+ if edit != 0 {
+ add_unwind_protect(
+ reset_attempted_completion_function as *mut c_void,
+ PT_NULL as *mut c_char,
+ );
+ add_unwind_protect(
+ bashline_reset_event_hook as *mut c_void,
+ PT_NULL as *mut c_char,
+ );
+ }
+ falarm(tmsec, tmusec);
+ }
- if bash_readline_initialized == 0 {
- initialize_readline();
- }
+ if nchars > 0 || delim != b'\n' as c_char {
+ //-d -n
+ if edit != 0 {
+ if nchars > 0 {
+ unwind_protect_mem(
+ &mut rl_num_chars_to_read as *mut c_int,
+ std::mem::size_of_val(&rl_num_chars_to_read) as c_int,
+ );
+ rl_num_chars_to_read = nchars;
+ }
- unwind_protect_mem(std::mem::transmute(rl_instream), std::mem::size_of_val(&rl_instream) as c_int);
- save_instream = rl_instream;
- rl_instream = libc::fdopen(fd, "r".as_ptr() as *const c_char);
+ if delim != b'\n' as c_char {
+ set_eol_delim(delim as c_int);
+ add_unwind_protect(reset_eol_delim as *mut c_void, PT_NULL as *mut c_char);
+ }
+ } else if input_is_tty != 0 {
+ //-d -n
+ termsave.fd = fd;
+ ttgetattr(fd, &mut ttattrs as *mut libc::termios);
+ termsave.attrs = ttattrs;
+
+ ttset = ttattrs;
+ if silent != 0 {
+ i = ttfd_cbreak(fd, std::mem::transmute(&ttset));
+ } else {
+ i = ttfd_onechar(fd, std::mem::transmute(&ttset));
+ }
- }
+ if i < 0 {
+ sh_ttyerror(1);
+ }
+ tty_modified = 1;
+ // add_unwind_protect(ttyrestore as *mut c_void, ptermsave);
+ add_unwind_protect(ttyrestore as *mut c_void, &mut termsave);
+ if interactive_shell == 0 {
+ initialize_terminating_signals();
+ }
+ }
+ } else if silent != 0 {
+ //-s
+ // termsave.unwrap().fd = fd;
+ termsave.fd = fd;
+ ttgetattr(fd, &mut ttattrs as *mut libc::termios);
+ // termsave.unwrap().attrs = ttattrs;
+ termsave.attrs = ttattrs;
+
+ ttset = ttattrs;
+ i = ttfd_noecho(fd, std::mem::transmute(&ttset));
+ if i < 0 {
+ sh_ttyerror(1);
+ }
- add_unwind_protect(xfree as *mut c_void, input_string);
- check_alrm();
- if nchars > 0 && input_is_tty == 0 && ignore_delim != 0 {
- unbuffered_read = 2;
- } else if nchars > 0 || delim != b'\n' as c_char || input_is_pipe != 0 {
- unbuffered_read = 1;
- }
+ tty_modified = 1;
+ add_unwind_protect(ttyrestore as *mut c_void, &mut termsave);
+ if interactive_shell == 0 {
+ initialize_terminating_signals();
+ }
+ }
- if !prompt.is_null() && edit == 0 { //-p no -e
- // eprintln!("{}", CStr::from_ptr(prompt).to_str().unwrap());
- eprint!("{}", CStr::from_ptr(prompt).to_str().unwrap());
+ save_instream = std::mem::zeroed();
+ if edit != 0 && fd != 0 {
+ if bash_readline_initialized == 0 {
+ initialize_readline();
+ }
- }
+ unwind_protect_mem(
+ std::mem::transmute(rl_instream),
+ std::mem::size_of_val(&rl_instream) as c_int,
+ );
+ save_instream = rl_instream;
+ rl_instream = libc::fdopen(fd, "r".as_ptr() as *const c_char);
+ }
- ps2 = PT_NULL as *mut c_char;
- print_ps2 = 0;
- eof = 0;
- retval = 0;
- 'get_input_string: loop {
- if sigalrm_seen != 0 {
- siglongjmp (std::mem::transmute(&alrmbuf), 1);
- }
+ add_unwind_protect(xfree as *mut c_void, input_string);
+ check_alrm();
+ if nchars > 0 && input_is_tty == 0 && ignore_delim != 0 {
+ unbuffered_read = 2;
+ } else if nchars > 0 || delim != b'\n' as c_char || input_is_pipe != 0 {
+ unbuffered_read = 1;
+ }
- if edit != 0 { //没有设置-e edit等于0
- if !rlbuf.is_null() &&
- *((rlbuf as usize + rlind as usize) as *mut c_char) == 0 &&
- delim != 0 {
- libc::free(rlbuf as *mut c_void);
- rlbuf = PT_NULL as *mut c_char;
+ if !prompt.is_null() && edit == 0 {
+ //-p no -e
+ // eprintln!("{}", CStr::from_ptr(prompt).to_str().unwrap());
+ eprint!("{}", CStr::from_ptr(prompt).to_str().unwrap());
}
- if rlbuf.is_null() {
- reading = 1;
- rlbuf = if prompt.is_null() {
- // edit_line("".as_ptr() as *mut c_char, itext)}
+
+ ps2 = PT_NULL as *mut c_char;
+ print_ps2 = 0;
+ eof = 0;
+ retval = 0;
+ 'get_input_string: loop {
+ if sigalrm_seen != 0 {
+ siglongjmp(std::mem::transmute(&alrmbuf), 1);
+ }
+
+ if edit != 0 {
+ //没有设置-e edit等于0
+ if !rlbuf.is_null()
+ && *((rlbuf as usize + rlind as usize) as *mut c_char) == 0
+ && delim != 0
+ {
+ libc::free(rlbuf as *mut c_void);
+ rlbuf = PT_NULL as *mut c_char;
+ }
+ if rlbuf.is_null() {
+ reading = 1;
+ rlbuf = if prompt.is_null() {
+ // edit_line("".as_ptr() as *mut c_char, itext)}
// let c_str = b'\0'; // b'\0'代表的是空字符串,和String::from("")不是同一个东西。
- edit_line(b'\0' as *mut c_char,itext) // b'\0'代表的是空字符串,和String::from("")不是同一个东西。
- }
- else {
+ edit_line(b'\0' as *mut c_char, itext) // b'\0'代表的是空字符串,和String::from("")不是同一个东西。
+ } else {
edit_line(prompt, itext)
};
- reading = 0;
- rlind = 0;
- }
- if rlbuf.is_null() {
- eof = 1;
- break 'get_input_string;
- }
- c = *((rlbuf as usize + rlind as usize) as *mut c_char);
- rlind += 1;
- } else {
- if print_ps2 != 0 {
- if ps2.is_null() {
- ps2 = get_string_value("PS2".as_ptr() as *const c_char);
- }
- eprintln!("{}", CStr::from_ptr(prompt).to_str().unwrap());
- print_ps2 = 0;
- }
+ reading = 0;
+ rlind = 0;
+ }
+ if rlbuf.is_null() {
+ eof = 1;
+ break 'get_input_string;
+ }
+ c = *((rlbuf as usize + rlind as usize) as *mut c_char);
+ rlind += 1;
+ } else {
+ if print_ps2 != 0 {
+ if ps2.is_null() {
+ ps2 = get_string_value("PS2".as_ptr() as *const c_char);
+ }
+ eprintln!("{}", CStr::from_ptr(prompt).to_str().unwrap());
+ print_ps2 = 0;
+ }
- reading = 1;
- check_alrm();
- *(libc::__errno_location()) = 0;
- if unbuffered_read == 2 {
- retval = if posixly_correct != 0 {
+ reading = 1;
+ check_alrm();
+ *(libc::__errno_location()) = 0;
+ if unbuffered_read == 2 {
+ retval = if posixly_correct != 0 {
zreadintr(fd, &mut c as *mut c_char, 1) as c_int
- }
- else {
+ } else {
zreadn(fd, &mut c as *mut c_char, (nchars - nr) as usize) as c_int
};
- } else if unbuffered_read != 0 {
- retval = if posixly_correct != 0 {
- zreadintr(fd, &mut c as *mut c_char, 1) as c_int}
- else {
- zread(fd, &mut c as *mut c_char, 1) as c_int};
- }
- else {
- retval = if posixly_correct != 0 {
+ } else if unbuffered_read != 0 {
+ retval = if posixly_correct != 0 {
+ zreadintr(fd, &mut c as *mut c_char, 1) as c_int
+ } else {
+ zread(fd, &mut c as *mut c_char, 1) as c_int
+ };
+ } else {
+ retval = if posixly_correct != 0 {
zreadcintr(fd, &mut c as *mut c_char) as c_int
- }
- else { //-a -t
+ } else {
+ //-a -t
zreadc(fd, &mut c as *mut c_char) as c_int
};
- }
- reading = 0;
-
- if retval <= 0 {
- let t = *libc::__errno_location();
- if retval < 0 && *libc::__errno_location() == libc::EINTR {
- check_signals();
- //lastsig = LASTSIG();
- if terminating_signal != 0 {
- lastsig = terminating_signal;
- } else {
- lastsig = if interrupt_state != 0 {libc::SIGINT} else { 0 };
}
-
- if lastsig == 0 {
- lastsig = trapped_signal_received;
+ reading = 0;
+
+ if retval <= 0 {
+ let t = *libc::__errno_location();
+ if retval < 0 && *libc::__errno_location() == libc::EINTR {
+ check_signals();
+ //lastsig = LASTSIG();
+ if terminating_signal != 0 {
+ lastsig = terminating_signal;
+ } else {
+ lastsig = if interrupt_state != 0 {
+ libc::SIGINT
+ } else {
+ 0
+ };
+ }
+
+ if lastsig == 0 {
+ lastsig = trapped_signal_received;
+ }
+ } else {
+ lastsig = 0;
+ }
+ if terminating_signal != 0 && tty_modified != 0 {
+ // ttyrestore();
+ ttyrestore(&mut termsave);
+ }
+ check_alrm();
+ eof = 1;
+ *libc::__errno_location() = t;
+ break 'get_input_string;
}
- } else {
- lastsig = 0;
- }
- if terminating_signal != 0 && tty_modified != 0 {
- // ttyrestore();
- ttyrestore(&mut termsave);
- }
- check_alrm();
- eof = 1;
- *libc::__errno_location() = t;
- break 'get_input_string;
- }
- quit();
- }
+ quit();
+ }
- if retval <= 0 {
- check_alrm();
- }
+ if retval <= 0 {
+ check_alrm();
+ }
- if mb_cur_max <= 4 {
- mb_cur_max = 4;
- }
- if i + mb_cur_max >= size {
- size += 128;
- let t: *mut c_char= xrealloc(input_string as *mut c_void, size as usize) as *mut c_char;
- if t != input_string {
- input_string = t;
- remove_unwind_protect();
- add_unwind_protect(xfree as *mut c_void, input_string);
- }
- }
-'out_add_char: loop {
- if pass_next != 0 {
- pass_next = 0;
- if c == b'\n' as c_char {
- if skip_ctlesc == 0 && i > 0 {i -= 1;}
- if interactive != 0 && input_is_tty != 0 && raw == 0 {print_ps2 = 1;}
- } else {
- break 'out_add_char;
- }
- continue 'get_input_string;
- }
+ if mb_cur_max <= 4 {
+ mb_cur_max = 4;
+ }
+ if i + mb_cur_max >= size {
+ size += 128;
+ let t: *mut c_char =
+ xrealloc(input_string as *mut c_void, size as usize) as *mut c_char;
+ if t != input_string {
+ input_string = t;
+ remove_unwind_protect();
+ add_unwind_protect(xfree as *mut c_void, input_string);
+ }
+ }
+ 'out_add_char: loop {
+ if pass_next != 0 {
+ pass_next = 0;
+ if c == b'\n' as c_char {
+ if skip_ctlesc == 0 && i > 0 {
+ i -= 1;
+ }
+ if interactive != 0 && input_is_tty != 0 && raw == 0 {
+ print_ps2 = 1;
+ }
+ } else {
+ break 'out_add_char;
+ }
+ continue 'get_input_string;
+ }
- if c == b'\\' as c_char && raw == 0 {
- pass_next += 1;
- if skip_ctlesc == 0 {
- saw_escape += 1;
- *((input_string as usize + i as usize) as *mut c_char) = CTLESC;
- i += 1;
- }
+ if c == b'\\' as c_char && raw == 0 {
+ pass_next += 1;
+ if skip_ctlesc == 0 {
+ saw_escape += 1;
+ *((input_string as usize + i as usize) as *mut c_char) = CTLESC;
+ i += 1;
+ }
- continue 'get_input_string;
- }
+ continue 'get_input_string;
+ }
- if ignore_delim == 0 && c == delim { //-a
- break 'get_input_string;
- }
+ if ignore_delim == 0 && c == delim {
+ //-a
+ break 'get_input_string;
+ }
- if c == b'\0' as c_char && delim != b'\0' as c_char {
- continue 'get_input_string;
- }
+ if c == b'\0' as c_char && delim != b'\0' as c_char {
+ continue 'get_input_string;
+ }
- if (skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL) {
- saw_escape += 1;
- *((input_string as usize + i as usize) as *mut c_char) = CTLESC;
- i += 1;
- }
- break 'out_add_char;
- }//out_add_char
+ if (skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL) {
+ saw_escape += 1;
+ *((input_string as usize + i as usize) as *mut c_char) = CTLESC;
+ i += 1;
+ }
+ break 'out_add_char;
+ } //out_add_char
- *((input_string as usize + i as usize) as *mut c_char) = c;
- i += 1;
- check_alrm();
+ *((input_string as usize + i as usize) as *mut c_char) = c;
+ i += 1;
+ check_alrm();
- if mb_cur_max > 1 && is_basic(c) == 0 {
+ if mb_cur_max > 1 && is_basic(c) == 0 {
+ *((input_string as usize + i as usize) as *mut c_char) = b'\0' as c_char;
+
+ if edit != 0 {
+ let clen = mbrlen(
+ (rlbuf as usize + rlind as usize - 1) as *const c_char,
+ mb_cur_max as usize,
+ std::mem::transmute(&PT_NULL),
+ );
+ if clen > 1 {
+ libc::memcpy(
+ (input_string as usize + i as usize) as *mut c_void,
+ (rlbuf as usize + rlind as usize) as *mut c_void,
+ (clen - 1) as size_t,
+ );
+ i += clen - 1;
+ rlind += clen - 1;
+ }
+ } else if locale_utf8locale == 0 || ((c as u8 & 0x80) != 0) {
+ i += read_mbchar(fd, input_string, i, c as c_int, unbuffered_read);
+ }
+ }
+ nr += 1;
+ if nchars > 0 && nr >= nchars {
+ break 'get_input_string;
+ }
+ } //get_input_string
*((input_string as usize + i as usize) as *mut c_char) = b'\0' as c_char;
+ check_alrm();
if edit != 0 {
- let clen = mbrlen((rlbuf as usize + rlind as usize - 1) as *const c_char,
- mb_cur_max as usize,
- std::mem::transmute(&PT_NULL));
- if clen > 1 {
- libc::memcpy( (input_string as usize + i as usize) as *mut c_void,
- (rlbuf as usize + rlind as usize) as *mut c_void, (clen - 1) as size_t);
- i += clen - 1;
- rlind += clen - 1;
- }
- } else if locale_utf8locale == 0 || ((c as u8 & 0x80) != 0) {
- i += read_mbchar(fd, input_string, i, c as c_int, unbuffered_read);
+ libc::free(rlbuf as *mut c_void);
}
- }
- nr += 1;
- if nchars > 0 && nr >= nchars {
- break 'get_input_string;
- }
-
- } //get_input_string
-
- *((input_string as usize + i as usize) as *mut c_char) = b'\0' as c_char;
- check_alrm();
- if edit != 0 {
- libc::free(rlbuf as *mut c_void);
- }
+ if retval < 0 {
+ t_errno = *libc::__errno_location();
+ if *libc::__errno_location() != EINTR {
+ let c_err = CString::new("read error: %d: %s").unwrap();
+ builtin_error(
+ c_err.as_ptr(),
+ fd,
+ libc::strerror(*libc::__errno_location()),
+ );
+ }
- if retval < 0 {
- t_errno = *libc::__errno_location();
- if *libc::__errno_location() != EINTR {
- let c_err = CString::new("read error: %d: %s").unwrap();
- builtin_error( c_err.as_ptr(), fd, libc::strerror(*libc::__errno_location()));
- }
+ run_unwind_frame(frame_name.as_ptr() as *mut c_char);
+ return if t_errno != EINTR {
+ EXECUTION_FAILURE
+ } else {
+ 128 + lastsig
+ };
+ }
- run_unwind_frame(frame_name.as_ptr() as *mut c_char);
- return if t_errno != EINTR {EXECUTION_FAILURE} else { 128 + lastsig};
- }
+ if tmsec > 0 || tmusec > 0 {
+ reset_alarm();
+ }
- if tmsec > 0 || tmusec > 0 {
- reset_alarm();
- }
+ if nchars > 0 || delim != b'\n' as c_char {
+ if edit != 0 {
+ if nchars > 0 {
+ rl_num_chars_to_read = 0;
+ }
+ if delim != b'\n' as c_char {
+ reset_eol_delim(0 as *mut c_char);
+ }
+ } else if input_is_tty != 0 {
+ // ttyrestore();
+ ttyrestore(&mut termsave);
+ }
+ } else if silent != 0 {
+ // ttyrestore();
+ ttyrestore(&mut termsave);
+ }
- if nchars > 0 || delim != b'\n' as c_char {
- if edit != 0 {
- if nchars > 0{
- rl_num_chars_to_read = 0;
+ // if unbuffered_read != 0 {
+ if unbuffered_read == 0 {
+ zsyncfd(fd);
}
- if delim != b'\n' as c_char{
- reset_eol_delim(0 as *mut c_char);
+
+ if !save_instream.is_null() {
+ rl_instream = save_instream;
}
- }
- else if input_is_tty != 0 {
- // ttyrestore();
- ttyrestore(&mut termsave);
- }
- }
- else if silent != 0 {
- // ttyrestore();
- ttyrestore(&mut termsave);
- }
- // if unbuffered_read != 0 {
- if unbuffered_read == 0 {
- zsyncfd(fd);
- }
+ discard_unwind_frame(frame_name.as_ptr() as *mut c_char);
- if !save_instream.is_null() {
- rl_instream = save_instream;
- }
+ retval = if eof != 0 {
+ EXECUTION_FAILURE
+ } else {
+ EXECUTION_SUCCESS
+ };
- discard_unwind_frame(frame_name.as_ptr() as *mut c_char);
+ break 'out_assig_vars;
+ } //out_assig_vars
+
+ if !arrayname.is_null() {
+ //和-a有关
+ if legal_identifier(arrayname) == 0 {
+ //标签不符合规范
+ // sh_invalidid(arrayname);
+ r_sh_invalidid(arrayname);
+ libc::free(input_string as *mut c_void);
+ return EXECUTION_FAILURE;
+ }
- retval = if eof != 0 {EXECUTION_FAILURE} else {EXECUTION_SUCCESS};
+ var = find_or_make_array_variable(arrayname, 1);
+ if var.is_null() {
+ libc::free(input_string as *mut c_void);
+ return EXECUTION_FAILURE; /* readonly or noassign */
+ }
+ if ((*var).attributes & 0x0000040) != 0 {
+ let c_err =
+ CString::new("%s: cannot convert associative to indexed array").unwrap();
+ builtin_error(c_err.as_ptr(), arrayname);
+ libc::free(input_string as *mut c_void);
+ return EXECUTION_FAILURE; /* existing associative array */
+ } else if ((*var).attributes & 0x0001000) != 0 {
+ (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
+ }
- break 'out_assig_vars;
-} //out_assig_vars
+ array_flush(std::mem::transmute((*var).value));
- if !arrayname.is_null() { //和-a有关
- if legal_identifier(arrayname) == 0 { //标签不符合规范
- // sh_invalidid(arrayname);
- r_sh_invalidid(arrayname);
- libc::free(input_string as *mut c_void);
- return EXECUTION_FAILURE;
- }
+ alist = list_string(input_string, ifs_chars, 0);
+ if !alist.is_null() {
+ if saw_escape != 0 {
+ dequote_list(alist);
+ } else {
+ word_list_remove_quoted_nulls(alist);
+ }
+ assign_array_var_from_word_list(var, alist, 0);
+ dispose_words(alist);
+ }
- var = find_or_make_array_variable(arrayname, 1);
- if var.is_null() {
- libc::free(input_string as *mut c_void);
- return EXECUTION_FAILURE; /* readonly or noassign */
- }
- if ((*var).attributes & 0x0000040) != 0 {
- let c_err = CString::new("%s: cannot convert associative to indexed array").unwrap();
- builtin_error(c_err.as_ptr(), arrayname);
libc::free(input_string as *mut c_void);
- return EXECUTION_FAILURE; /* existing associative array */
- } else if ((*var).attributes & 0x0001000) != 0 {
- (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
- }
- array_flush(std::mem::transmute((*var).value));
+ return retval;
+ }
- alist = list_string(input_string, ifs_chars, 0);
- if !alist.is_null() {
- if saw_escape != 0 {
- dequote_list(alist);
- } else {
- word_list_remove_quoted_nulls(alist);
+ if list.is_null() {
+ //和-d相关 -n 0可以退出,有显示
+ if saw_escape != 0 {
+ let t = dequote_string(input_string);
+ var = bind_variable("REPLY".as_ptr() as *const c_char, t, 0);
+ libc::free(t as *mut c_void);
+ } else {
+ var = bind_variable("REPLY".as_ptr() as *const c_char, input_string, 0);
+ }
+ let cond = var.is_null()
+ || ((*var).attributes & 0x0000002) != 0
+ || ((*var).attributes & 0x0004000) != 0;
+ if cond {
+ retval = EXECUTION_FAILURE;
+ } else {
+ (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
}
- assign_array_var_from_word_list(var, alist, 0);
- dispose_words(alist);
- }
- libc::free(input_string as *mut c_void);
+ libc::free(input_string as *mut c_void);
+ return retval;
+ }
- return retval;
- }
+ orig_input_string = input_string;
- if list.is_null() { //和-d相关 -n 0可以退出,有显示
- if saw_escape != 0 {
- let t = dequote_string(input_string);
- var = bind_variable("REPLY".as_ptr() as *const c_char, t, 0);
- libc::free(t as *mut c_void);
- } else {
- var = bind_variable("REPLY".as_ptr() as *const c_char, input_string, 0);
- }
- let cond = var.is_null() || ((*var).attributes & 0x0000002) != 0 || ((*var).attributes & 0x0004000) != 0;
- if cond {
- retval = EXECUTION_FAILURE;
- } else {
- (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
+ let mut t = input_string;
+ while !ifs_chars.is_null()
+ && *ifs_chars != 0
+ && (*t == b' ' as c_char || *t == b'\t' as c_char || *t == b'\n' as c_char)
+ && (ifs_cmap[*t as usize] != 0)
+ {
+ t = (t as usize + 1) as *mut c_char;
}
+ input_string = t;
- libc::free(input_string as *mut c_void);
- return retval;
- }
-
- orig_input_string = input_string;
+ while !(*list).next.is_null() {
+ varname = (*((*list).word)).word;
- let mut t = input_string;
- while !ifs_chars.is_null() && *ifs_chars != 0 &&
- (*t == b' ' as c_char|| *t == b'\t' as c_char || *t == b'\n' as c_char) &&
- (ifs_cmap[*t as usize] != 0) {
- t = (t as usize + 1) as *mut c_char;
- }
- input_string = t;
+ if legal_identifier(varname) == 0 && valid_array_reference(varname, vflags) == 0 {
+ // sh_invalidid(varname);
+ r_sh_invalidid(varname);
+ libc::free(orig_input_string as *mut c_void);
+ return EXECUTION_FAILURE;
+ }
- while !(*list).next.is_null() {
- varname = (*((*list).word)).word;
+ if *input_string != 0 {
+ t = get_word_from_string(
+ std::mem::transmute(&input_string),
+ ifs_chars,
+ std::mem::transmute(&e),
+ );
+ if !t.is_null() {
+ *e = b'\0' as c_char;
+ }
- if legal_identifier(varname) == 0 &&
- valid_array_reference(varname, vflags) == 0 {
- // sh_invalidid(varname);
- r_sh_invalidid(varname);
- libc::free(orig_input_string as *mut c_void);
- return EXECUTION_FAILURE;
- }
+ if !t.is_null() && saw_escape != 0 {
+ let t1 = dequote_string(t);
+ var = bind_read_variable(varname, t1);
+ libc::free(t1 as *mut c_void);
+ } else {
+ var = bind_read_variable(
+ varname,
+ if !t.is_null() {
+ t
+ } else {
+ "".as_ptr() as *mut c_char
+ },
+ );
+ }
+ } else {
+ t = PT_NULL as *mut c_char;
+ var = bind_read_variable(varname, "".as_ptr() as *mut c_char);
+ }
- if *input_string != 0 {
- t = get_word_from_string(std::mem::transmute(&input_string), ifs_chars, std::mem::transmute(&e));
- if !t.is_null() { *e = b'\0' as c_char;}
+ if !t.is_null() {
+ libc::free(t as *mut c_void);
+ }
- if !t.is_null() && saw_escape != 0 {
- let t1 = dequote_string(t);
- var = bind_read_variable(varname, t1);
- libc::free(t1 as *mut c_void);
- } else {
- var = bind_read_variable(varname, if !t.is_null() {t} else {"".as_ptr() as *mut c_char});
+ if var.is_null() {
+ libc::free(orig_input_string as *mut c_void);
+ return EXECUTION_FAILURE;
}
- } else {
- t = PT_NULL as *mut c_char;
- var = bind_read_variable(varname, "".as_ptr() as *mut c_char);
- }
- if !t.is_null() {
- libc::free(t as *mut c_void);
+ stupidly_hack_special_variables(varname);
+ (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
+
+ list = (*list).next;
}
- if var.is_null() {
+ if legal_identifier((*((*list).word)).word) == 0
+ && valid_array_reference((*((*list).word)).word, vflags) == 0
+ {
+ // sh_invalidid((*((*list).word)).word);
+ r_sh_invalidid((*((*list).word)).word);
libc::free(orig_input_string as *mut c_void);
return EXECUTION_FAILURE;
}
- stupidly_hack_special_variables(varname);
- (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
-
- list = (*list).next;
- }
-
- if legal_identifier((*((*list).word)).word) == 0 &&
- valid_array_reference((*((*list).word)).word, vflags) == 0 {
- // sh_invalidid((*((*list).word)).word);
- r_sh_invalidid((*((*list).word)).word);
- libc::free(orig_input_string as *mut c_void);
- return EXECUTION_FAILURE;
- }
+ tofree = PT_NULL as *mut c_char;
+ if *input_string != 0 {
+ t1 = input_string;
+ t = get_word_from_string(
+ std::mem::transmute(&input_string),
+ ifs_chars,
+ std::mem::transmute(&e),
+ );
+ if *input_string == 0 {
+ input_string = t;
+ tofree = input_string;
+ } else {
+ input_string = strip_trailing_ifs_whitespace(t1, ifs_chars, saw_escape);
+ tofree = t;
+ }
+ }
- tofree = PT_NULL as *mut c_char;
- if *input_string != 0 {
- t1 = input_string;
- t = get_word_from_string(std::mem::transmute(&input_string), ifs_chars, std::mem::transmute(&e));
- if *input_string == 0 {
- input_string = t;
- tofree = input_string;
+ if saw_escape != 0 && !input_string.is_null() && *input_string != 0 {
+ t = dequote_string(input_string);
+ var = bind_read_variable((*((*list).word)).word, t);
+ libc::free(t as *mut c_void);
} else {
- input_string = strip_trailing_ifs_whitespace(t1, ifs_chars, saw_escape);
- tofree = t;
+ var = bind_read_variable(
+ (*((*list).word)).word,
+ if !input_string.is_null() {
+ input_string
+ } else {
+ "".as_ptr() as *mut c_char
+ },
+ );
}
- }
-
- if saw_escape != 0 && !input_string.is_null() && *input_string != 0 {
- t = dequote_string(input_string);
- var = bind_read_variable((*((*list).word)).word, t);
- libc::free(t as *mut c_void);
- } else {
- var = bind_read_variable((*((*list).word)).word, if !input_string.is_null() {input_string} else {"".as_ptr() as *mut c_char});
- }
- if !var.is_null() {
- stupidly_hack_special_variables((*((*list).word)).word);
- (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
- } else {
- retval = EXECUTION_FAILURE;
- }
+ if !var.is_null() {
+ stupidly_hack_special_variables((*((*list).word)).word);
+ (*var).attributes &= ((*var).attributes as u32 ^ 0xffffffff as u32) as i32;
+ } else {
+ retval = EXECUTION_FAILURE;
+ }
- if !tofree.is_null() {
- libc::free(tofree as *mut c_void);
- }
- libc::free(orig_input_string as *mut c_void);
- return retval;
-} //unsafe
+ if !tofree.is_null() {
+ libc::free(tofree as *mut c_void);
+ }
+ libc::free(orig_input_string as *mut c_void);
+ return retval;
+ } //unsafe
}
/* ---------------------------------------------------------------------------------- */
@@ -833,183 +908,151 @@ unsafe {
// }
#[inline]
-unsafe extern "C" fn is_basic(mut c:libc::c_char)->libc::c_int{
+unsafe extern "C" fn is_basic(c: libc::c_char) -> libc::c_int {
return (*is_basic_table
.as_ptr()
- .offset((c as libc::c_uchar as libc::c_int>>5 as libc::c_int)as isize)
- >>(c as libc::c_uchar as libc::c_int & 31 as libc::c_int)
+ .offset((c as libc::c_uchar as libc::c_int >> 5 as libc::c_int) as isize)
+ >> (c as libc::c_uchar as libc::c_int & 31 as libc::c_int)
& 1 as libc::c_int as libc::c_uint) as libc::c_int;
}
-pub fn bind_read_variable(name: *mut c_char, value: *mut c_char) -> * mut SHELL_VAR {
+pub fn bind_read_variable(name: *mut c_char, value: *mut c_char) -> *mut SHELL_VAR {
let v: *mut SHELL_VAR;
-unsafe {
- // v = builtin_bind_variable(name, value, 0);
- v = r_builtin_bind_variable(name, value, 0);
-
- if v.is_null() {
- return v;
- } else {
- if ((*v).attributes & 0x0000002) != 0 || ((*v).attributes & 0x0004000) != 0 {
- return PT_NULL as *mut SHELL_VAR;
- } else {
+ unsafe {
+ v = r_builtin_bind_variable(name, value, 0);
+
+ if v.is_null() {
return v;
+ } else {
+ if ((*v).attributes & 0x0000002) != 0 || ((*v).attributes & 0x0004000) != 0 {
+ return PT_NULL as *mut SHELL_VAR;
+ } else {
+ return v;
+ }
}
}
}
-}
fn read_mbchar(fd: c_int, string: *mut c_char, ind: c_int, ch: c_int, unbuffered: c_int) -> c_int {
let mut i: size_t = 1;
let mut r: ssize_t;
- let mut c: c_char = 0;
- let mut ret: ssize_t;
-
-unsafe {
- let mut mbchar: [c_char; MB_LEN_MAX as usize + 1] = std::mem::zeroed();
- let mut ps: mbstate_t = std::mem::zeroed();
- let mut ps_back: mbstate_t = std::mem::zeroed();
- let mut wc: libc::wchar_t = std::mem::zeroed();
-
-'out: loop {
- mbchar[0] = ch as c_char;
- for n in 0..= MB_LEN_MAX {
- ps_back = ps;
- ret = mbrtowc(std::mem::transmute(&wc), std::mem::transmute(&mbchar), i, std::mem::transmute(&ps)) as ssize_t;
- if ret == -2 {
- ps = ps_back;
-
- /* We don't want to be interrupted during a multibyte char read */
- if unbuffered == 2 {
- r = zreadn(fd, std::mem::transmute(&c), 1);
- } else if unbuffered != 0 {
- r = zread(fd, std::mem::transmute(&c), 1);
- } else {
- r = zreadc(fd, std::mem::transmute(&c));
- }
- if r <= 0 {
- break 'out;
+ let c: c_char = 0;
+ let mut ret: ssize_t;
+
+ unsafe {
+ let mut mbchar: [c_char; MB_LEN_MAX as usize + 1] = std::mem::zeroed();
+ let mut ps: mbstate_t = std::mem::zeroed();
+ let mut ps_back: mbstate_t = std::mem::zeroed();
+ let wc: libc::wchar_t = std::mem::zeroed();
+
+ 'out: loop {
+ mbchar[0] = ch as c_char;
+ for _n in 0..=MB_LEN_MAX {
+ ps_back = ps;
+ ret = mbrtowc(
+ std::mem::transmute(&wc),
+ std::mem::transmute(&mbchar),
+ i,
+ std::mem::transmute(&ps),
+ ) as ssize_t;
+ if ret == -2 {
+ ps = ps_back;
+
+ /* We don't want to be interrupted during a multibyte char read */
+ if unbuffered == 2 {
+ r = zreadn(fd, std::mem::transmute(&c), 1);
+ } else if unbuffered != 0 {
+ r = zread(fd, std::mem::transmute(&c), 1);
+ } else {
+ r = zreadc(fd, std::mem::transmute(&c));
+ }
+ if r <= 0 {
+ break 'out;
+ }
+ mbchar[i] = c;
+ i += 1;
+ continue;
+ } else if ret == -1 || ret == 0 || ret > 0 {
+ break;
+ }
}
- mbchar[i] = c;
- i += 1;
- continue;
- } else if ret == -1 || ret == 0 || ret > 0 {
- break;
+ break 'out;
}
- }
- break 'out;
-}
- if i > 1 {
- r = 1;
- while r < i as isize {
- *((string as usize + ind as usize + r as usize -1) as *mut c_char) = mbchar[r as size_t];
+ if i > 1 {
+ r = 1;
+ while r < i as isize {
+ *((string as usize + ind as usize + r as usize - 1) as *mut c_char) =
+ mbchar[r as size_t];
- r += 1;
+ r += 1;
+ }
}
+ return (i - 1) as c_int;
}
- return (i - 1) as c_int;
-}
}
fn quit() {
-unsafe {
- if terminating_signal != 0 {
- termsig_handler(terminating_signal);
- }
+ unsafe {
+ if terminating_signal != 0 {
+ termsig_handler(terminating_signal);
+ }
- if interrupt_state != 0 {
- throw_to_top_level();
+ if interrupt_state != 0 {
+ throw_to_top_level();
+ }
}
}
-}
fn check_alrm() {
unsafe {
if sigalrm_seen != 0 {
- siglongjmp (std::mem::transmute(&alrmbuf), 1);
- // siglongjmp (&mut alrmbuf as *mut __jmp_buf_tag, 1);
+ siglongjmp(std::mem::transmute(&alrmbuf), 1);
}
}
}
static mut old_attempted_completion_function: usize = 0;
-pub fn reset_attempted_completion_function(cp: *mut c_char)
-{
-unsafe {
- if rl_attempted_completion_function as usize == 0 &&
- old_attempted_completion_function as usize != 0 {
- rl_attempted_completion_function = std::mem::transmute(old_attempted_completion_function);
+pub fn reset_attempted_completion_function(_cp: *mut c_char) {
+ unsafe {
+ if rl_attempted_completion_function as usize == 0
+ && old_attempted_completion_function as usize != 0
+ {
+ rl_attempted_completion_function =
+ std::mem::transmute(old_attempted_completion_function);
+ }
}
}
-}
static mut old_startup_hook: usize = 0;
static mut deftext: *mut c_char = PT_NULL as *mut c_char;
-fn set_itext() -> c_int
-{
+fn set_itext() -> c_int {
let mut r1 = 0;
let mut r2 = 0;
-unsafe {
- if old_startup_hook != 0 {
- let fp: rl_hook_func_t = std::mem::transmute(old_startup_hook);
- r1 = fp();
+ unsafe {
+ if old_startup_hook != 0 {
+ let fp: rl_hook_func_t = std::mem::transmute(old_startup_hook);
+ r1 = fp();
+ }
+ if !deftext.is_null() {
+ r2 = rl_insert_text(deftext as *const c_char);
+ deftext = PT_NULL as *mut c_char;
+ rl_startup_hook = std::mem::transmute(old_startup_hook);
+ old_startup_hook = std::mem::transmute(0 as usize);
+ }
}
- if !deftext.is_null() {
- r2 = rl_insert_text(deftext as *const c_char);
- deftext = PT_NULL as *mut c_char;
- rl_startup_hook = std::mem::transmute(old_startup_hook);
- old_startup_hook = std::mem::transmute(0 as usize);
- }
-}
- return (r1 != 0 || r2 != 0) as c_int;
+ return (r1 != 0 || r2 != 0) as c_int;
}
-// fn edit_line(p : *mut c_char, itext : *mut c_char) -> *mut c_char {
-// unsafe {
-// if bash_readline_initialized == 0 {
-// initialize_readline();
-// }
-
-// old_attempted_completion_function = std::mem::transmute(rl_attempted_completion_function);
-// rl_attempted_completion_function = std::mem::transmute(0 as usize);
-// bashline_set_event_hook();
-// if !itext.is_null() {
-// old_startup_hook = std::mem::transmute(rl_startup_hook);
-// rl_startup_hook = std::mem::transmute(set_itext as usize);
-// deftext = itext;
-// }
-
-// let mut ret = readline(p);
-
-// rl_attempted_completion_function = std::mem::transmute(old_attempted_completion_function);
-// old_attempted_completion_function = std::mem::transmute(0 as usize);
-// bashline_reset_event_hook();
-
-// if ret.is_null() {
-// return ret;
-// }
-
-// let len:i32 = libc::strlen(ret) as i32;
-// ret = xrealloc(ret as *mut c_void, (len + 2) as usize) as *mut c_char;
-// // *ret = delim;
-// *ret.offset(len as isize) = delim;
-// *((ret as usize + 1) as *mut c_char) = b'\0' as c_char;
-
-// return ret;
-// }
-// }
-
-
-fn edit_line(p : *mut c_char, itext : *mut c_char) -> *mut c_char {
- let mut len:i32;
+fn edit_line(p: *mut c_char, itext: *mut c_char) -> *mut c_char {
+ let mut len: i32;
unsafe {
if bash_readline_initialized == 0 {
initialize_readline();
}
-
+
old_attempted_completion_function = std::mem::transmute(rl_attempted_completion_function);
rl_attempted_completion_function = std::mem::transmute(0 as usize);
bashline_set_event_hook();
@@ -1018,76 +1061,57 @@ fn edit_line(p : *mut c_char, itext : *mut c_char) -> *mut c_char {
rl_startup_hook = std::mem::transmute(set_itext as usize);
deftext = itext;
}
-
+
let mut ret = readline(p);
-
+
rl_attempted_completion_function = std::mem::transmute(old_attempted_completion_function);
old_attempted_completion_function = std::mem::transmute(0 as usize);
bashline_reset_event_hook();
-
+
if ret.is_null() {
return ret;
}
-
+
len = libc::strlen(ret) as i32;
ret = xrealloc(ret as *mut c_void, (len + 2) as usize) as *mut c_char;
*ret.offset(len as isize) = delim;
len += 1;
- *ret.offset(len as isize) = b'\0' as c_char;
+ *ret.offset(len as isize) = b'\0' as c_char;
return ret;
}
}
-
-
-fn sigalrm(s : c_int) {
-unsafe {
- sigalrm_seen = 1;
-}
+fn sigalrm(_s: c_int) {
+ unsafe {
+ sigalrm_seen = 1;
+ }
}
-fn reset_alarm()
-{
-unsafe {
- falarm(0, 0);
- set_signal_handler(libc::SIGALRM, old_alrm);
-}
+fn reset_alarm() {
+ unsafe {
+ falarm(0, 0);
+ set_signal_handler(libc::SIGALRM, old_alrm);
+ }
}
-// fn ttyrestore()
-// {
-// unsafe {
-// if termsave.is_none() {
-// let tmp: tty_save = std::mem::zeroed();
-// termsave = Some(tmp);
-// }
-
-// let ter = termsave.unwrap();
-// ttsetattr(ter.fd, std::mem::transmute(&(ter.attrs)));
-// tty_modified = 0;
-// }
-// }
-
-unsafe extern "C" fn ttyrestore(mut ttp:*mut tty_save){
- ttsetattr((*ttp).fd,&mut (*ttp).attrs);
+unsafe extern "C" fn ttyrestore(ttp: *mut tty_save) {
+ ttsetattr((*ttp).fd, &mut (*ttp).attrs);
tty_modified = 0 as libc::c_int;
}
#[no_mangle]
-pub extern "C" fn read_tty_cleanup()
-{
-unsafe {
- if tty_modified != 0 {
- ttyrestore(&mut termsave);
+pub extern "C" fn read_tty_cleanup() {
+ unsafe {
+ if tty_modified != 0 {
+ ttyrestore(&mut termsave);
+ }
}
}
-}
#[no_mangle]
-pub extern "C" fn read_tty_modified() -> c_int
-{
-unsafe {
- return tty_modified;
+pub extern "C" fn read_tty_modified() -> c_int {
+ unsafe {
+ return tty_modified;
}
}
@@ -1097,76 +1121,45 @@ static mut old_newline_ctype: c_int = 0;
static mut old_newline_func: usize = 0;
static mut delim_char: u8 = 0;
-// fn set_eol_delim(c: c_int)
-// {
-// unsafe {
-// if bash_readline_initialized == 0 {
-// initialize_readline();
-// }
-
-// let cmap = rl_get_keymap();
-// let n = std::mem::size_of_val(&*cmap);
-// let ret_pos = (b'M' & 0x1f) as usize * n;
-// let c_pos = (c & 0x1f) as usize * n;
-
-// /* Save the old delimiter char binding */
-// old_newline_ctype = (*((cmap as usize + ret_pos) as Keymap)).tp as c_int;
-// old_newline_func = (*((cmap as usize + ret_pos) as Keymap)).function as usize;
-// old_delim_ctype = (*((cmap as usize + c_pos) as Keymap)).tp as c_int;
-// old_delim_func = (*((cmap as usize + c_pos) as Keymap)).function as usize;
-
-// /* Change newline to self-insert */
-// (*((cmap as usize + ret_pos) as Keymap)).tp = ISFUNC as c_char;
-// (*((cmap as usize + ret_pos) as Keymap)).function = rl_insert;
-
-// /* Bind the delimiter character to accept-line. */
-// (*((cmap as usize + c_pos) as Keymap)).tp = ISFUNC as c_char;
-// (*((cmap as usize + c_pos) as Keymap)).function = rl_newline;
-
-// delim_char = c as u8;
-// }
-// }
-fn set_eol_delim(c: c_int)
-{
- let mut cmap:Keymap;
-unsafe {
- if bash_readline_initialized == 0 {
- initialize_readline();
- }
+fn set_eol_delim(c: c_int) {
+ let cmap: Keymap;
+ unsafe {
+ if bash_readline_initialized == 0 {
+ initialize_readline();
+ }
- // let cmap = rl_get_keymap();
- cmap = rl_get_keymap();
+ // let cmap = rl_get_keymap();
+ cmap = rl_get_keymap();
- old_newline_ctype = (*cmap.offset((b'M' as i32 & 0x1f) as isize)).tp as c_int;
- old_newline_func = (*cmap.offset((b'M' as i32 & 0x1f) as isize)).function as usize;
- old_delim_ctype = (*cmap.offset(c as isize)).tp as c_int;
- old_delim_func = (*cmap.offset(c as isize)).function as usize;
+ old_newline_ctype = (*cmap.offset((b'M' as i32 & 0x1f) as isize)).tp as c_int;
+ old_newline_func = (*cmap.offset((b'M' as i32 & 0x1f) as isize)).function as usize;
+ old_delim_ctype = (*cmap.offset(c as isize)).tp as c_int;
+ old_delim_func = (*cmap.offset(c as isize)).function as usize;
- /* Change newline to self-insert */
- (*cmap.offset((b'M' as i32 & 0x1f) as isize)).tp = ISFUNC as c_char;
- (*cmap.offset((b'M' as i32 & 0x1f) as isize)).function = rl_insert;
+ /* Change newline to self-insert */
+ (*cmap.offset((b'M' as i32 & 0x1f) as isize)).tp = ISFUNC as c_char;
+ (*cmap.offset((b'M' as i32 & 0x1f) as isize)).function = rl_insert;
- /* Bind the delimiter character to accept-line. */
- (*cmap.offset(c as isize)).tp = ISFUNC as c_char;
- (*cmap.offset(c as isize)).function = rl_newline;
+ /* Bind the delimiter character to accept-line. */
+ (*cmap.offset(c as isize)).tp = ISFUNC as c_char;
+ (*cmap.offset(c as isize)).function = rl_newline;
- delim_char = c as u8;
-}
+ delim_char = c as u8;
+ }
}
-fn reset_eol_delim(cp: *mut c_char)
-{
-unsafe {
- let cmap = rl_get_keymap();
- let n = std::mem::size_of_val(&*cmap);
- let ret_pos = (b'M' & 0x1f) as usize * n;
- let delim_pos = (delim_char & 0x1f) as usize * n;
+fn reset_eol_delim(_cp: *mut c_char) {
+ unsafe {
+ let cmap = rl_get_keymap();
+ let n = std::mem::size_of_val(&*cmap);
+ let ret_pos = (b'M' & 0x1f) as usize * n;
+ let delim_pos = (delim_char & 0x1f) as usize * n;
- (*((cmap as usize + ret_pos) as Keymap)).tp = old_newline_ctype as c_char;
- (*((cmap as usize + ret_pos) as Keymap)).function = std::mem::transmute(old_newline_func);
+ (*((cmap as usize + ret_pos) as Keymap)).tp = old_newline_ctype as c_char;
+ (*((cmap as usize + ret_pos) as Keymap)).function = std::mem::transmute(old_newline_func);
- (*((cmap as usize + delim_pos) as Keymap)).tp = old_delim_ctype as c_char;
- (*((cmap as usize + delim_pos) as Keymap)).function = std::mem::transmute(old_delim_func);
-}
+ (*((cmap as usize + delim_pos) as Keymap)).tp = old_delim_ctype as c_char;
+ (*((cmap as usize + delim_pos) as Keymap)).function = std::mem::transmute(old_delim_func);
+ }
}
diff --git a/bash-5.1/builtins_rust/rlet/src/lib.rs b/bash-5.1/builtins_rust/rlet/src/lib.rs
index 20799dc1ad9ce09162e0825808e35ed893a25ae8..187122117b90da3f7d554e9adac8f35075b0871a 100644
--- a/bash-5.1/builtins_rust/rlet/src/lib.rs
+++ b/bash-5.1/builtins_rust/rlet/src/lib.rs
@@ -1,69 +1,80 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
+use libc::{c_char, c_int, c_long, c_void};
use std::ffi::CStr;
-use libc::{c_int, c_char, c_long, c_void};
-
include!(concat!("intercdep.rs"));
#[no_mangle]
pub extern "C" fn r_let_builtin(mut list: *mut WordList) -> i32 {
-unsafe {
- let mut ret: c_long = 0;
- let mut expok: c_int = 0;
+ unsafe {
+ let mut ret: c_long = 0;
+ let expok: c_int = 0;
- if !list.is_null() && !(*list).word.is_null() &&
- libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0 {
- r_builtin_help ();
- return EX_USAGE;
- }
+ if !list.is_null()
+ && !(*list).word.is_null()
+ && libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
- if !list.is_null() && !(*list).word.is_null() && is_option((*((*list).word)).word, b'-') {
- list = (*list).next;
- }
+ if !list.is_null() && !(*list).word.is_null() && is_option((*((*list).word)).word, b'-') {
+ list = (*list).next;
+ }
- if list.is_null() {
- let names = String::from("letwarn");
- err_translate_fn(&names,std::ptr::null_mut());
- println!();
- return EXECUTION_FAILURE;
- }
+ if list.is_null() {
+ let names = String::from("letwarn");
+ err_translate_fn(&names, std::ptr::null_mut());
+ println!();
+ return EXECUTION_FAILURE;
+ }
- while !list.is_null() {
- ret = evalexp((*((*list).word)).word, EXP_EXPANDED, std::mem::transmute(&expok));
- if expok == 0 {
- return EXECUTION_FAILURE;
+ while !list.is_null() {
+ ret = evalexp(
+ (*((*list).word)).word,
+ EXP_EXPANDED,
+ std::mem::transmute(&expok),
+ );
+ if expok == 0 {
+ return EXECUTION_FAILURE;
+ }
+ list = (*list).next;
}
- list = (*list).next;
- }
- return if ret == 0 {EXECUTION_FAILURE} else {EXECUTION_SUCCESS};
-}
+ return if ret == 0 {
+ EXECUTION_FAILURE
+ } else {
+ EXECUTION_SUCCESS
+ };
+ }
}
#[no_mangle]
-pub extern "C" fn r_exp_builtin(mut list: *mut WordList) -> i32 {
-
-unsafe {
- let mut expok: c_int = 0;
+pub extern "C" fn r_exp_builtin(list: *mut WordList) -> i32 {
+ unsafe {
+ let expok: c_int = 0;
- if list.is_null() {
- let names = String::from("letwarn");
- err_translate_fn(&names,std::ptr::null_mut());
- println!();
- return EXECUTION_FAILURE;
- }
+ if list.is_null() {
+ let names = String::from("letwarn");
+ err_translate_fn(&names, std::ptr::null_mut());
+ println!();
+ return EXECUTION_FAILURE;
+ }
- let exp = string_list(list);
- let ret = evalexp(exp, EXP_EXPANDED, std::mem::transmute(&expok));
- libc::free(exp as *mut c_void);
- return if ret == 0 || expok == 0 {EXECUTION_FAILURE} else {EXECUTION_SUCCESS};
-}
+ let exp = string_list(list);
+ let ret = evalexp(exp, EXP_EXPANDED, std::mem::transmute(&expok));
+ libc::free(exp as *mut c_void);
+ return if ret == 0 || expok == 0 {
+ EXECUTION_FAILURE
+ } else {
+ EXECUTION_SUCCESS
+ };
+ }
}
-unsafe fn is_option(s: *mut c_char, c: u8) -> bool
-{
+unsafe fn is_option(s: *mut c_char, c: u8) -> bool {
let str = CStr::from_ptr(s).to_bytes_with_nul();
- return str[0] == b'-' && str[1] == c && str[2] != 0
+ return str[0] == b'-' && str[1] == c && str[2] != 0;
}
diff --git a/bash-5.1/builtins_rust/rreturn/src/lib.rs b/bash-5.1/builtins_rust/rreturn/src/lib.rs
index 09ab272d20ea70916b7049989043526dbf3aad0d..4b15e1eae022f15afde5c83582262eafef693159 100644
--- a/bash-5.1/builtins_rust/rreturn/src/lib.rs
+++ b/bash-5.1/builtins_rust/rreturn/src/lib.rs
@@ -1,28 +1,31 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char, c_long, c_ulong};
-use rcommon::{r_get_exitstat,WordList};
+use libc::{c_char, c_int, c_long, c_ulong};
+use rcommon::{r_get_exitstat, WordList};
include!(concat!("intercdep.rs"));
use rhelp::r_builtin_help;
#[no_mangle]
pub extern "C" fn r_return_builtin(list: *mut WordList) -> i32 {
+ unsafe {
+ if !list.is_null()
+ && !(*list).word.is_null()
+ && libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
-unsafe {
- if !list.is_null() && !(*list).word.is_null() &&
- libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0 {
- r_builtin_help ();
- return EX_USAGE;
+ return_catch_value = r_get_exitstat(list);
+ if return_catch_flag != 0 {
+ siglongjmp(std::mem::transmute(&return_catch), 1);
+ } else {
+ builtin_error(
+ "can only `return' from a function or sourced script\0".as_ptr() as *const c_char,
+ );
+ return EX_USAGE;
+ }
}
-
- return_catch_value = r_get_exitstat(list);
- if return_catch_flag != 0 {
- siglongjmp(std::mem::transmute(&return_catch), 1);
- } else {
- builtin_error("can only `return' from a function or sourced script\0".as_ptr() as *const c_char);
- return EX_USAGE;
- }
-}
return EXECUTION_SUCCESS;
}
diff --git a/bash-5.1/builtins_rust/set/src/lib.rs b/bash-5.1/builtins_rust/set/src/lib.rs
index ee9ee4299c30e2e2660fbc5f6392331e5817a3a8..3fac789d6b5153594f896734ea7f89c65dd8952d 100644
--- a/bash-5.1/builtins_rust/set/src/lib.rs
+++ b/bash-5.1/builtins_rust/set/src/lib.rs
@@ -1,218 +1,214 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate libc;
extern crate nix;
-use std::ffi::CStr;
-use std::ffi::CString;
-use std::ptr;
-use std::mem;
-use std::io;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage, r_savestring};
+use std::ffi::{CStr, CString};
+use std::{ptr, mem, io};
+use rcommon::{
+ r_builtin_usage, r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS,
+ EX_NOEXEC, EX_NOTFOUND, EX_USAGE, SUBSHELL_PAREN,
+};
use rhelp::r_builtin_help;
#[macro_export]
macro_rules! FLAG_UNKNOWN {
- () => {0 as *mut i32}
+ () => {
+ 0 as *mut i32
+ };
}
#[macro_export]
-macro_rules! MINUS_O_FORMAT{
- () => {CString::new("%-15s\t%s\n")}
+macro_rules! MINUS_O_FORMAT {
+ () => {
+ CString::new("%-15s\t%s\n")
+ };
}
#[macro_export]
- macro_rules! GET_BINARY_O_OPTION_VALUE {
- ($a:expr,$b:expr) =>{
+macro_rules! GET_BINARY_O_OPTION_VALUE {
+ ($a:expr,$b:expr) => {
if (o_options[$a as usize].get_func).is_some() {
- (Some(
- (o_options[$a as usize].get_func)
- .expect("non-null function pointer"),
- ))
- .expect("non-null function pointer")($b)
- } else {
- *o_options[$a as usize].variable
- }
- }
+ (Some((o_options[$a as usize].get_func).expect("non-null function pointer")))
+ .expect("non-null function pointer")($b)
+ } else {
+ *o_options[$a as usize].variable
+ }
+ };
}
#[macro_export]
macro_rules! SET_BINARY_O_OPTION_VALUE {
- ($a:expr,$onoff:expr,$c:expr) =>{
- unsafe {
- if (o_options[ $a as usize].set_func).is_some() {
- (Some(
- (o_options[$a as usize].set_func)
- .expect("non-null function pointer"),
- ))
- .expect("non-null function pointer")($onoff, $c)
- }
- else {
- $onoff == FLAG_ON!();
- let b = $onoff;
- *o_options[$a as usize].variable = b;
- *o_options[$a as usize].variable
- }
- }
- }
+ ($a:expr,$onoff:expr,$c:expr) => {
+ unsafe {
+ if (o_options[$a as usize].set_func).is_some() {
+ (Some((o_options[$a as usize].set_func).expect("non-null function pointer")))
+ .expect("non-null function pointer")($onoff, $c)
+ } else {
+ $onoff == FLAG_ON!();
+ let b = $onoff;
+ *o_options[$a as usize].variable = b;
+ *o_options[$a as usize].variable
+ }
+ }
+ };
}
#[macro_export]
macro_rules! N_O_OPTIONS {
- () => {
- (std::mem::size_of::<[opp;28]>() as usize
- / std::mem::size_of::() as usize)
- }
+ () => {
+ (std::mem::size_of::<[opp; 28]>() as usize / std::mem::size_of::() as usize)
+ };
}
#[macro_export]
-macro_rules! FLAG_ON{
- () =>{
- b'-' as i32
- }
+macro_rules! FLAG_ON {
+ () => {
+ b'-' as i32
+ };
}
#[macro_export]
-macro_rules! FLAG_OFF{
- () =>{
- b'+' as i32
- }
+macro_rules! FLAG_OFF {
+ () => {
+ b'+' as i32
+ };
}
#[macro_export]
-macro_rules! VUNSETATTR{
- ($var:expr,$attr:expr) => {
- (*$var).attributes = (*$var).attributes & !(&$attr);
- (*$var).attributes
- }
+macro_rules! VUNSETATTR {
+ ($var:expr,$attr:expr) => {
+ (*$var).attributes = (*$var).attributes & !(&$attr);
+ (*$var).attributes
+ };
}
#[macro_export]
macro_rules! att_exported {
- () => {
- 0x0000001
- }
+ () => {
+ 0x0000001
+ };
}
#[macro_export]
-macro_rules! exported_p {
- ($var:expr) => {
- (*$var).attributes & att_exported!()
- }
+macro_rules! exported_p {
+ ($var:expr) => {
+ (*$var).attributes & att_exported!()
+ };
}
#[macro_export]
macro_rules! VSETATTR {
- ($var:expr,$attr:expr) => {
- (*$var).attributes = (*$var).attributes | (&$attr);
- (*$var).attributes
- }
+ ($var:expr,$attr:expr) => {
+ (*$var).attributes = (*$var).attributes | (&$attr);
+ (*$var).attributes
+ };
}
#[macro_export]
-macro_rules! imported_p {
- ($var:expr) => {
- (*$var).attributes & att_imported!()
- }
+macro_rules! imported_p {
+ ($var:expr) => {
+ (*$var).attributes & att_imported!()
+ };
}
#[macro_export]
macro_rules! att_imported {
- () => {
- 0x0008000
- }
+ () => {
+ 0x0008000
+ };
}
#[macro_export]
-macro_rules! att_assoc{
- () => {
- 0x0000040
- }
+macro_rules! att_assoc {
+ () => {
+ 0x0000040
+ };
}
#[macro_export]
macro_rules! assoc_p {
- ($var:expr) => {
- (*$var).attributes & att_assoc!()
- }
+ ($var:expr) => {
+ (*$var).attributes & att_assoc!()
+ };
}
#[macro_export]
macro_rules! array_p {
- ($var:expr) => {
- (*$var).attributes & att_array!()
- }
+ ($var:expr) => {
+ (*$var).attributes & att_array!()
+ };
}
#[macro_export]
-macro_rules! non_unsettable_p {
- ($var:expr) => {
- (*$var).attributes & att_nounset!()
- }
+macro_rules! non_unsettable_p {
+ ($var:expr) => {
+ (*$var).attributes & att_nounset!()
+ };
}
#[macro_export]
macro_rules! readonly_p {
- ($var:expr) => {
- (*$var).attributes & att_readonly!()
- }
+ ($var:expr) => {
+ (*$var).attributes & att_readonly!()
+ };
}
#[macro_export]
macro_rules! nameref_p {
- ($var:expr) => {
- (*$var).attributes & att_nameref!()
- }
+ ($var:expr) => {
+ (*$var).attributes & att_nameref!()
+ };
}
#[macro_export]
macro_rules! nameref_cell {
- ($var:expr) => {
- (*$var).value
- }
+ ($var:expr) => {
+ (*$var).value
+ };
}
#[macro_export]
-macro_rules! att_nameref{
- () => {
- 0x0000800
- }
+macro_rules! att_nameref {
+ () => {
+ 0x0000800
+ };
}
#[macro_export]
-macro_rules! att_readonly{
- () => {
- 0x0000002
- }
+macro_rules! att_readonly {
+ () => {
+ 0x0000002
+ };
}
#[macro_export]
macro_rules! att_nounset {
- () => {
- 0x0002000
- }
+ () => {
+ 0x0002000
+ };
}
#[macro_export]
macro_rules! name_cell {
- ($var:expr) => {
- (*$var).name
- }
+ ($var:expr) => {
+ (*$var).name
+ };
}
#[macro_export]
-macro_rules! att_array{
- () => {
- 0x0000004
- }
+macro_rules! att_array {
+ () => {
+ 0x0000004
+ };
}
#[macro_export]
macro_rules! value_cell {
- ($var:expr) => {
- (*$var).value
- }
+ ($var:expr) => {
+ (*$var).value
+ };
}
#[derive(Copy, Clone)]
@@ -229,23 +225,14 @@ pub struct variable {
#[derive(Copy, Clone)]
#[repr(C)]
- pub struct opp{
- name : *mut libc::c_char,
- letter : i32,
- variable : *mut i32,
- set_func : Option::,
- get_func : Option::,
+pub struct opp {
+ name: *mut libc::c_char,
+ letter: i32,
+ variable: *mut i32,
+ set_func: Option,
+ get_func: Option,
}
-// #[deny(missing_fragment_specifier)]
-// #[macro_export]
-// macro_rules! STREQ{
-// ($a:expr,$b:expr) =>{
-// (*$a==*$b) && (libc::strcmp($a,$b)==0)
-// }
-// }
-
-
#[macro_export]
macro_rules! FLAG_ERROR{
() => {-1}
@@ -262,632 +249,466 @@ macro_rules! VA_ONEWORD {
}
#[no_mangle]
-pub static mut o_options : [opp ; 28] = unsafe {[
- {
- opp{
- name : b"allexport\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'a' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >
- (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
- }
- },
-
- {
- opp{
- name : b"braceexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'B' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func:
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,>
- (0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"emacs\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func : Some(set_edit_mode),
- get_func : Some(get_edit_mode)
- }
- },
-
- {
- opp{
- name : b"errexit\0" as *const u8 as *const libc::c_char as *mut libc::c_char ,
- letter : b'e' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp {
- name : b"errtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'E' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp {
- name : b"functrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'T' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp {
- name : b"hashall\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'h' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"histexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'H' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- // variable : 0 as *const libc::c_void
- // as *mut libc::c_void
- // as *mut i32,
- variable : &enable_history_list as *const i32 as *mut i32,
- set_func : Some (bash_set_history),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"ignoreeof\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- /*variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32, */
- variable : &ignoreeof as *const i32 as *mut i32,
- set_func : Some (set_ignoreeof),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"interactive-comments\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- /*variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32, */
- variable : &interactive_comments as *const i32 as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"keyword\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'k' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"monitor\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'm' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"noclobber\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'C' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"noexec\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'n' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"noglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'f' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"nolog\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- /*variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32, */
- variable : &dont_save_function_defs as *const i32 as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"notify\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'b' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"nounset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'u' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"onecmd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b't' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"physical\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'P' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"pipefail\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- /*variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32, */
- variable : &pipefail_opt as *const i32 as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"posix\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- /*variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32, */
- variable : &posixly_correct as *const libc::c_int as *mut libc::c_int,
- set_func : Some(set_posix_mode),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"privileged\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'p' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"verbose\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'v' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : b"vi\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'\0' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func : Some(set_edit_mode), //set_edit_mode as *mut setopt_set_func_t ,// unsafe {&mut set_edit_mode},
- get_func : Some(get_edit_mode)
- }
- },
-
- {
- opp{
- name : b"xtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
- letter : b'x' as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- },
-
- {
- opp{
- name : std::ptr::null_mut() ,
- letter : 0 as i32,
- variable : 0 as *const libc::c_void
- as *mut libc::c_void
- as *mut i32,
- set_func :
- ::std::mem::transmute::< *mut libc::c_void,
- Option::,
- > (0 as *const libc::c_void as *mut libc::c_void),
- get_func :
- ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void)
- }
- }
-
-]};
+pub static mut o_options: [opp; 28] = unsafe {
+ [
+ {
+ opp {
+ name: b"allexport\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'a' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"braceexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'B' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"emacs\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: Some(set_edit_mode),
+ get_func: Some(get_edit_mode),
+ }
+ },
+ {
+ opp {
+ name: b"errexit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'e' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"errtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'E' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"functrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'T' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"hashall\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'h' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"histexpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'H' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"history\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ // variable : 0 as *const libc::c_void
+ // as *mut libc::c_void
+ // as *mut i32,
+ variable: &enable_history_list as *const i32 as *mut i32,
+ set_func: Some(bash_set_history),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"ignoreeof\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ /*variable : 0 as *const libc::c_void
+ as *mut libc::c_void
+ as *mut i32, */
+ variable: &ignoreeof as *const i32 as *mut i32,
+ set_func: Some(set_ignoreeof),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"interactive-comments\0" as *const u8 as *const libc::c_char
+ as *mut libc::c_char,
+ letter: b'\0' as i32,
+ /*variable : 0 as *const libc::c_void
+ as *mut libc::c_void
+ as *mut i32, */
+ variable: &interactive_comments as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"keyword\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'k' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"monitor\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'm' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"noclobber\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'C' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"noexec\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'n' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"noglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'f' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"nolog\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ /*variable : 0 as *const libc::c_void
+ as *mut libc::c_void
+ as *mut i32, */
+ variable: &dont_save_function_defs as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"notify\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'b' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"nounset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'u' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"onecmd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b't' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"physical\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'P' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"pipefail\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ /*variable : 0 as *const libc::c_void
+ as *mut libc::c_void
+ as *mut i32, */
+ variable: &pipefail_opt as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"posix\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ /*variable : 0 as *const libc::c_void
+ as *mut libc::c_void
+ as *mut i32, */
+ variable: &posixly_correct as *const libc::c_int as *mut libc::c_int,
+ set_func: Some(set_posix_mode),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"privileged\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'p' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"verbose\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'v' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: b"vi\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'\0' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: Some(set_edit_mode), //set_edit_mode as *mut setopt_set_func_t ,// unsafe {&mut set_edit_mode},
+ get_func: Some(get_edit_mode),
+ }
+ },
+ {
+ opp {
+ name: b"xtrace\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ letter: b'x' as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ {
+ opp {
+ name: std::ptr::null_mut(),
+ letter: 0 as i32,
+ variable: 0 as *const libc::c_void as *mut libc::c_void as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ get_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
+ }
+ },
+ ]
+};
extern "C" {
- fn setopt_set_func_t (i :i32 , name : *mut libc::c_char) -> i32;
- fn setopt_get_func_t (name : *mut libc::c_char)-> i32;
- fn xmalloc(_: u64) -> *mut libc::c_void;
- fn unbind_variable_noref(_: *const libc::c_char) -> i32;
- fn unbind_nameref(_: *const libc::c_char) -> i32;
- fn unbind_func(_: *const libc::c_char) -> i32;
- fn strvec_create(_: i32) -> *mut *mut libc::c_char;
- fn all_shell_variables() -> *mut *mut SHELL_VAR;
- fn print_var_list(_: *mut *mut SHELL_VAR);
- fn print_func_list(_: *mut *mut SHELL_VAR);
- fn change_flag(_: i32, _: i32) -> i32;
- fn strlen(_: *const libc::c_char) -> u64;
- fn builtin_usage();
- fn find_function (name:* const libc::c_char)->* mut SHELL_VAR;
- fn bind_variable(
- _: *const libc::c_char,
- _: *mut libc::c_char,
- _: i32,
- ) -> *mut SHELL_VAR;
+ fn setopt_set_func_t(i: i32, name: *mut libc::c_char) -> i32;
+ fn setopt_get_func_t(name: *mut libc::c_char) -> i32;
+ fn xmalloc(_: u64) -> *mut libc::c_void;
+ fn unbind_variable_noref(_: *const libc::c_char) -> i32;
+ fn unbind_nameref(_: *const libc::c_char) -> i32;
+ fn unbind_func(_: *const libc::c_char) -> i32;
+ fn strvec_create(_: i32) -> *mut *mut libc::c_char;
+ fn all_shell_variables() -> *mut *mut SHELL_VAR;
+ fn print_var_list(_: *mut *mut SHELL_VAR);
+ fn print_func_list(_: *mut *mut SHELL_VAR);
+ fn change_flag(_: i32, _: i32) -> i32;
+ fn strlen(_: *const libc::c_char) -> u64;
+ fn builtin_usage();
+ fn find_function(name: *const libc::c_char) -> *mut SHELL_VAR;
+ fn bind_variable(_: *const libc::c_char, _: *mut libc::c_char, _: i32) -> *mut SHELL_VAR;
fn find_variable(_: *const libc::c_char) -> *mut SHELL_VAR;
- fn rl_variable_bind (_: *const libc::c_char, _: *const libc::c_char) -> i32;
- fn find_variable_last_nameref(
- _: *const libc::c_char,
- _: i32,
- ) -> *mut SHELL_VAR;
+ fn rl_variable_bind(_: *const libc::c_char, _: *const libc::c_char) -> i32;
+ fn find_variable_last_nameref(_: *const libc::c_char, _: i32) -> *mut SHELL_VAR;
+
+ fn extract_colon_unit(_: *mut libc::c_char, _: *mut i32) -> *mut libc::c_char;
- fn extract_colon_unit(
- _: *mut libc::c_char,
- _: *mut i32,
- ) -> *mut libc::c_char;
-
- fn valid_array_reference (
- _ : *const libc::c_char ,
- _ : i32
- )-> i32;
-
- fn array_variable_part (
- _: *const libc::c_char,
- _: i32,
- _:*mut *mut libc::c_char,
- _:*mut i32
+ fn valid_array_reference(_: *const libc::c_char, _: i32) -> i32;
+
+ fn array_variable_part(
+ _: *const libc::c_char,
+ _: i32,
+ _: *mut *mut libc::c_char,
+ _: *mut i32,
) -> *mut SHELL_VAR;
- fn all_shell_functions () -> *mut *mut SHELL_VAR;
- fn num_posix_options() -> i32;
- fn find_flag(_: i32) -> *mut i32;
- fn internal_getopt (list:*mut WordList , opts:*mut libc::c_char)->i32;
- fn get_posix_options(_: *mut libc::c_char) -> *mut libc::c_char;
- fn sh_chkwrite (_:i32)->i32;
- fn reset_internal_getopt();
- fn sh_invalidopt (value:* mut libc::c_char);
- fn sv_ignoreeof (_ : *mut libc::c_char);
- fn sv_strict_posix (_: *mut libc::c_char);
- fn with_input_from_stdin();
- fn sh_invalidoptname (value:* mut libc::c_char);
- fn bash_history_enable();
- fn load_history();
- fn bash_history_disable();
- fn remember_args (list:* mut WordList, argc:i32);
- fn sh_invalidid (value:* mut libc::c_char);
- fn legal_identifier (_:*const libc::c_char) -> i32;
- fn unbind_array_element(_: *mut SHELL_VAR, _:*mut libc::c_char,_: i32) -> i32;
- fn unbind_variable (_: *const libc::c_char) -> i32;
- fn with_input_from_stream (_:libc::FILE , _: *const libc::c_char);
- fn stupidly_hack_special_variables (_ : *mut libc::c_char);
- fn builtin_error(_: *const libc::c_char, _: ...);
- static mut posixly_correct : i32;
- static mut enable_history_list : i32;
- static mut ignoreeof : i32 ;
- static mut interactive_comments : i32;
- static mut dont_save_function_defs : i32;
- static mut pipefail_opt : i32;
- static mut mark_modified_vars: i32;
- static mut remember_on_history: i32;
- static mut optflags: [libc::c_char; 0];
- static mut list_opttype:i32;
- static mut no_line_editing :i32;
- static mut interactive : i32;
- static mut interactive_shell : i32;
- static mut history_lines_this_session : i32;
- static mut rl_editing_mode : i32;
- static mut list_optopt :i8;
- static mut loptend:*mut WordList;
- static assoc_expand_once:i32;
- static mut stdin : libc::FILE;
+ fn all_shell_functions() -> *mut *mut SHELL_VAR;
+ fn num_posix_options() -> i32;
+ fn find_flag(_: i32) -> *mut i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut libc::c_char) -> i32;
+ fn get_posix_options(_: *mut libc::c_char) -> *mut libc::c_char;
+ fn sh_chkwrite(_: i32) -> i32;
+ fn reset_internal_getopt();
+ fn sh_invalidopt(value: *mut libc::c_char);
+ fn sv_ignoreeof(_: *mut libc::c_char);
+ fn sv_strict_posix(_: *mut libc::c_char);
+ fn with_input_from_stdin();
+ fn sh_invalidoptname(value: *mut libc::c_char);
+ fn bash_history_enable();
+ fn load_history();
+ fn bash_history_disable();
+ fn remember_args(list: *mut WordList, argc: i32);
+ fn sh_invalidid(value: *mut libc::c_char);
+ fn legal_identifier(_: *const libc::c_char) -> i32;
+ fn unbind_array_element(_: *mut SHELL_VAR, _: *mut libc::c_char, _: i32) -> i32;
+ fn unbind_variable(_: *const libc::c_char) -> i32;
+ fn with_input_from_stream(_: libc::FILE, _: *const libc::c_char);
+ fn stupidly_hack_special_variables(_: *mut libc::c_char);
+ fn builtin_error(_: *const libc::c_char, _: ...);
+ static mut posixly_correct: i32;
+ static mut enable_history_list: i32;
+ static mut ignoreeof: i32;
+ static mut interactive_comments: i32;
+ static mut dont_save_function_defs: i32;
+ static mut pipefail_opt: i32;
+ static mut mark_modified_vars: i32;
+ static mut remember_on_history: i32;
+ static mut optflags: [libc::c_char; 0];
+ static mut list_opttype: i32;
+ static mut no_line_editing: i32;
+ static mut interactive: i32;
+ static mut interactive_shell: i32;
+ static mut history_lines_this_session: i32;
+ static mut rl_editing_mode: i32;
+ static mut list_optopt: i8;
+ static mut loptend: *mut WordList;
+ static assoc_expand_once: i32;
+ static mut stdin: libc::FILE;
}
-type setopt_set_func_t = unsafe extern "C" fn (
- i :i32 ,
- name : *mut libc::c_char
-) -> i32;
+type setopt_set_func_t = unsafe extern "C" fn(i: i32, name: *mut libc::c_char) -> i32;
-type setopt_get_func_t = unsafe extern "C" fn (
- name : *mut libc::c_char
-) -> i32;
+type setopt_get_func_t = unsafe extern "C" fn(name: *mut libc::c_char) -> i32;
-type sh_var_value_func_t = unsafe extern "C" fn (
- _ : *mut SHELL_VAR
-) -> *mut SHELL_VAR;
+type sh_var_value_func_t = unsafe extern "C" fn(_: *mut SHELL_VAR) -> *mut SHELL_VAR;
-type sh_var_assign_func_t = unsafe extern "C" fn (
- _ : *mut SHELL_VAR ,
- _ : *mut libc::c_char,
- _ : arrayind_t,
- _ : *mut libc::c_char
+type sh_var_assign_func_t = unsafe extern "C" fn(
+ _: *mut SHELL_VAR,
+ _: *mut libc::c_char,
+ _: arrayind_t,
+ _: *mut libc::c_char,
) -> *mut SHELL_VAR;
//type check = String::from_utf8(cc::Build::new().file("../builtins/set.def").expand()).unwrap();
@@ -897,48 +718,47 @@ static mut previous_option_value: i32 = 0;
pub type SHELL_VAR = variable;
pub type arrayind_t = i64;
-unsafe fn STREQ( a:* const libc::c_char, b:* const libc::c_char)->bool {
- //println!("hahhahahhahahah");
- //println!("a is {:?}, b is {:?}",CStr::from_ptr(a),CStr::from_ptr(b));
- return (*a ==*b) && (libc::strcmp(a, b) == 0);
+unsafe fn STREQ(a: *const libc::c_char, b: *const libc::c_char) -> bool {
+ //println!("hahhahahhahahah");
+ //println!("a is {:?}, b is {:?}",CStr::from_ptr(a),CStr::from_ptr(b));
+ return (*a == *b) && (libc::strcmp(a, b) == 0);
}
-unsafe fn find_minus_o_option (mut name : *mut libc::c_char) -> i32 {
- //println! ("enter find_minus_o_option");
- let mut i : i32 = 0;
- for j in 0..N_O_OPTIONS!()-1 {
- i = j as i32;
- //println! ("i is {}, j is {}",i,j);
- let ooo = o_options[j];
- //println! ("i is {}, j is {}",i,j);
- if STREQ(name, o_options[j as usize].name) {
- return i;
+unsafe fn find_minus_o_option(mut name: *mut libc::c_char) -> i32 {
+ //println! ("enter find_minus_o_option");
+ let mut i: i32 = 0;
+ for j in 0..N_O_OPTIONS!() - 1 {
+ i = j as i32;
+ //println! ("i is {}, j is {}",i,j);
+ let ooo = o_options[j];
+ //println! ("i is {}, j is {}",i,j);
+ if STREQ(name, o_options[j as usize].name) {
+ return i;
+ }
}
- }
- -1
+ -1
}
-unsafe fn minus_o_option_value (name : *mut libc::c_char) -> i32{
- let mut i : i32 = 0;
- let mut on_or_off : *mut i32 = 0 as *mut i32;
+unsafe fn minus_o_option_value(name: *mut libc::c_char) -> i32 {
+ let mut i: i32 = 0;
+ let mut on_or_off: *mut i32 = 0 as *mut i32;
- i = find_minus_o_option (name);
- if i < 0 {
- return -1;
- }
- let options = o_options [i as usize ];
- if unsafe {options.letter != 0}{
- if on_or_off == FLAG_UNKNOWN!() {
+ i = find_minus_o_option(name);
+ if i < 0 {
return -1;
}
- return unsafe {*on_or_off};
+ let options = o_options[i as usize];
+ if unsafe { options.letter != 0 } {
+ if on_or_off == FLAG_UNKNOWN!() {
+ return -1;
+ }
+ return unsafe { *on_or_off };
+ } else {
+ unsafe { GET_BINARY_O_OPTION_VALUE!(i, name) }
}
- else{
- unsafe {GET_BINARY_O_OPTION_VALUE!(i, name)}
- }
}
-unsafe fn print_minus_o_option (name : *mut libc::c_char, value : i32, pflag : i32){
+unsafe fn print_minus_o_option(name: *mut libc::c_char, value: i32, pflag: i32) {
if pflag == 0 {
if value > 0 {
println!("{:?} {:?}", CStr::from_ptr(name), CStr::from_ptr(on));
@@ -1109,24 +929,26 @@ unsafe extern "C" fn set_ignoreeof (on_or_off : i32 , option_name : *mut libc::c
return 0;
}
-unsafe extern "C" fn set_posix_mode (on_or_off : i32 , option_name : *mut libc::c_char) -> i32 {
- if (on_or_off == FLAG_ON!() && posixly_correct != 0 ) ||
- (on_or_off == FLAG_OFF!() && posixly_correct == 0){
+unsafe extern "C" fn set_posix_mode(on_or_off: i32, option_name: *mut libc::c_char) -> i32 {
+ if (on_or_off == FLAG_ON!() && posixly_correct != 0)
+ || (on_or_off == FLAG_OFF!() && posixly_correct == 0)
+ {
+ return 0;
+ }
+ on_or_off == FLAG_ON!();
+ posixly_correct = on_or_off;
+
+ if posixly_correct != 0 {
+ unbind_variable_noref(b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char);
+ } else {
+ bind_variable(
+ b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char,
+ b"y\0" as *const u8 as *mut libc::c_char,
+ 0,
+ );
+ }
+ sv_strict_posix(b"POSIXLY_CORRECT\0" as *const u8 as *mut libc::c_char);
return 0;
- }
- on_or_off == FLAG_ON!();
- posixly_correct = on_or_off ;
-
- if posixly_correct != 0 {
- unbind_variable_noref(b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char);
- }
-
- else {
- bind_variable (b"POSIXLY_CORRECT\0" as *const u8 as *const libc::c_char,
- b"y\0" as *const u8 as *mut libc::c_char, 0);
- }
- sv_strict_posix (b"POSIXLY_CORRECT\0" as *const u8 as *mut libc::c_char);
- return 0;
}
unsafe extern "C" fn set_edit_mode (on_or_off : i32 , option_name : *mut libc::c_char) -> i32{
@@ -1230,102 +1052,100 @@ unsafe fn set_minus_o_option (on_or_off : i32, option_name : *mut libc::c_char)
}
}
-unsafe fn print_all_shell_variables (){
-
- let mut vars = 0 as *mut *mut SHELL_VAR;
+unsafe fn print_all_shell_variables() {
+ let mut vars = 0 as *mut *mut SHELL_VAR;
- vars = all_shell_variables ();
- if vars != std::ptr::null_mut() {
- print_var_list (vars);
- libc::free (*vars as *mut libc::c_void );
+ vars = all_shell_variables();
+ if vars != std::ptr::null_mut() {
+ print_var_list(vars);
+ libc::free(*vars as *mut libc::c_void);
}
- /* POSIX.2 does not allow function names and definitions to be output when
- `set' is invoked without options (PASC Interp #202). */
- if posixly_correct == 0 {
- vars = all_shell_functions ();
- if vars != std::ptr::null_mut() {
- print_func_list (vars);
- libc::free (*vars as *mut libc::c_void );
- }
+ /* POSIX.2 does not allow function names and definitions to be output when
+ `set' is invoked without options (PASC Interp #202). */
+ if posixly_correct == 0 {
+ vars = all_shell_functions();
+ if vars != std::ptr::null_mut() {
+ print_func_list(vars);
+ libc::free(*vars as *mut libc::c_void);
+ }
}
}
-pub unsafe fn r_set_shellopts () {
- //println!("set shellopts by huanhuan");
- let mut value : *mut libc::c_char;
- let mut tflag : [libc::c_char;N_O_OPTIONS!()] = [0 as libc::c_char ;N_O_OPTIONS!()];
- let mut vsize : i32 = 0;
- let mut i: i32 = 0;
- let mut vptr : i32 ;
- let mut ip :*mut i32 ;
- let mut exported : i32;
-
- let mut v : *mut SHELL_VAR;
- for j in 0..N_O_OPTIONS!() {
- i = j as i32;
- if o_options[i as usize].name != std::ptr::null_mut(){
- tflag[i as usize] = 0;
- if o_options[i as usize].letter != 0 {
- ip = find_flag (o_options[i as usize].letter);
- if ip != std::ptr::null_mut() && unsafe {*ip} != 0{
- vsize = vsize + unsafe {strlen (o_options[i as usize].name) as u64 as u32 as i32 } + 1;
- tflag[i as usize] = 1;
- }
- }
- else if unsafe {GET_BINARY_O_OPTION_VALUE!(i,o_options[i as usize].name)} != 0{
- vsize = vsize + unsafe {strlen (o_options[i as usize].name) as i32} + 1;
- tflag[i as usize] = 1;
- }
+pub unsafe fn r_set_shellopts() {
+ //println!("set shellopts by huanhuan");
+ let mut value: *mut libc::c_char;
+ let mut tflag: [libc::c_char; N_O_OPTIONS!()] = [0 as libc::c_char; N_O_OPTIONS!()];
+ let mut vsize: i32 = 0;
+ let mut i: i32 = 0;
+ let mut vptr: i32;
+ let mut ip: *mut i32;
+ let mut exported: i32;
+
+ let mut v: *mut SHELL_VAR;
+ for j in 0..N_O_OPTIONS!() {
+ i = j as i32;
+ if o_options[i as usize].name != std::ptr::null_mut() {
+ tflag[i as usize] = 0;
+ if o_options[i as usize].letter != 0 {
+ ip = find_flag(o_options[i as usize].letter);
+ if ip != std::ptr::null_mut() && unsafe { *ip } != 0 {
+ vsize = vsize
+ + unsafe { strlen(o_options[i as usize].name) as u64 as u32 as i32 }
+ + 1;
+ tflag[i as usize] = 1;
+ }
+ } else if unsafe { GET_BINARY_O_OPTION_VALUE!(i, o_options[i as usize].name) } != 0 {
+ vsize = vsize + unsafe { strlen(o_options[i as usize].name) as i32 } + 1;
+ tflag[i as usize] = 1;
+ }
+ }
}
- }
- value = unsafe {xmalloc((vsize + 1) as u32 as u64) as *mut libc::c_char};
- vptr = 0;
+ value = unsafe { xmalloc((vsize + 1) as u32 as u64) as *mut libc::c_char };
+ vptr = 0;
- for j in 0..N_O_OPTIONS!(){
- i = j as i32;
- if o_options[i as usize].name != std::ptr::null_mut(){
- if tflag[i as usize] != 0 as libc::c_char {
- unsafe {
- libc::strcpy (value.offset(vptr as isize), o_options[i as usize].name);
- vptr = vptr + strlen (o_options[i as usize].name) as u64 as i64 as i32;
+ for j in 0..N_O_OPTIONS!() {
+ i = j as i32;
+ if o_options[i as usize].name != std::ptr::null_mut() {
+ if tflag[i as usize] != 0 as libc::c_char {
+ unsafe {
+ libc::strcpy(value.offset(vptr as isize), o_options[i as usize].name);
+ vptr = vptr + strlen(o_options[i as usize].name) as u64 as i64 as i32;
+ }
+ *value.offset(vptr as isize) = b':' as libc::c_char;
+ vptr = vptr + 1;
+ }
}
- *value.offset(vptr as isize) = b':' as libc::c_char;
- vptr = vptr+1;
- }
}
- }
- if vptr > 0 {
- vptr = vptr-1;
- }
- *value.offset(vptr as isize) = b'\0' as libc::c_char;
+ if vptr > 0 {
+ vptr = vptr - 1;
+ }
+ *value.offset(vptr as isize) = b'\0' as libc::c_char;
- v = find_variable (b"SHELLOPTS\0" as *const u8 as *mut libc::c_char);
+ v = find_variable(b"SHELLOPTS\0" as *const u8 as *mut libc::c_char);
- /* Turn off the read-only attribute so we can bind the new value, and
- note whether or not the variable was exported. */
- if v != std::ptr::null_mut(){
- VUNSETATTR!(v, att_readonly!());
- exported = exported_p!(v);
+ /* Turn off the read-only attribute so we can bind the new value, and
+ note whether or not the variable was exported. */
+ if v != std::ptr::null_mut() {
+ VUNSETATTR!(v, att_readonly!());
+ exported = exported_p!(v);
+ } else {
+ exported = 0;
}
- else {
- exported = 0;
- }
- v = bind_variable (b"SHELLOPTS\0" as *const u8 as *mut libc::c_char, value, 0);
- /* Turn the read-only attribute back on, and turn off the export attribute
- if it was set implicitly by mark_modified_vars and SHELLOPTS was not
- exported before we bound the new value. */
-
- VSETATTR!(v, att_readonly!());
-
- if mark_modified_vars!= 0 && exported != 0 && exported_p!(v) != 0 {
-
- VUNSETATTR!(v, att_exported!());
- }
- libc::free (value as *mut libc::c_void );
+ v = bind_variable(b"SHELLOPTS\0" as *const u8 as *mut libc::c_char, value, 0);
+ /* Turn the read-only attribute back on, and turn off the export attribute
+ if it was set implicitly by mark_modified_vars and SHELLOPTS was not
+ exported before we bound the new value. */
+ VSETATTR!(v, att_readonly!());
+
+ if mark_modified_vars != 0 && exported != 0 && exported_p!(v) != 0 {
+ VUNSETATTR!(v, att_exported!());
+ }
+ libc::free(value as *mut libc::c_void);
}
+
unsafe fn parse_shellopts (value : *mut libc::c_char) {
let mut vname : *mut libc::c_char;
let mut vptr : i32 = 0;
@@ -1339,39 +1159,38 @@ unsafe fn parse_shellopts (value : *mut libc::c_char) {
};
}
-unsafe fn initialize_shell_options (no_shellopts : i32) {
- let mut temp: *mut libc::c_char;
- let mut var : *mut SHELL_VAR = 0 as *mut SHELL_VAR;
-
- if no_shellopts == 0 {
- var = find_variable (b"SHELLOPTS\0" as *const u8 as *const libc::c_char);
- /* set up any shell options we may have inherited. */
- if !var.is_null() && imported_p!(var) != 0 {
- if assoc_p! (var) != 0 || array_p !(var) != 0{
- temp = std::ptr::null_mut();
- }
- else {
- temp = r_savestring(value_cell!(var));
- }
+unsafe fn initialize_shell_options(no_shellopts: i32) {
+ let mut temp: *mut libc::c_char;
+ let mut var: *mut SHELL_VAR = 0 as *mut SHELL_VAR;
+
+ if no_shellopts == 0 {
+ var = find_variable(b"SHELLOPTS\0" as *const u8 as *const libc::c_char);
+ /* set up any shell options we may have inherited. */
+ if !var.is_null() && imported_p!(var) != 0 {
+ if assoc_p!(var) != 0 || array_p!(var) != 0 {
+ temp = std::ptr::null_mut();
+ } else {
+ temp = r_savestring(value_cell!(var));
+ }
- if temp != std::ptr::null_mut() {
- parse_shellopts (temp);
- libc::free (temp as *mut libc::c_void );
- }
- }
+ if temp != std::ptr::null_mut() {
+ parse_shellopts(temp);
+ libc::free(temp as *mut libc::c_void);
+ }
+ }
}
- /* Set up the $SHELLOPTS variable. */
- r_set_shellopts ();
+ /* Set up the $SHELLOPTS variable. */
+ r_set_shellopts();
}
-unsafe fn reset_shell_options () {
- pipefail_opt = 0;
- ignoreeof = 0 ;
- posixly_correct = 0 ;
- dont_save_function_defs = 0;
- enable_history_list = 1 ;
- remember_on_history = enable_history_list ;
+unsafe fn reset_shell_options() {
+ pipefail_opt = 0;
+ ignoreeof = 0;
+ posixly_correct = 0;
+ dont_save_function_defs = 0;
+ enable_history_list = 1;
+ remember_on_history = enable_history_list;
}
#[no_mangle]
@@ -1433,10 +1252,7 @@ unsafe fn reset_shell_options () {
r_builtin_help();
return EX_USAGE;
}
- // unsafe {
- // builtin_usage ();
- // }
- // return EX_USAGE;
+
}
}
// opt = unsafe {internal_getopt(list, optflags.as_ptr() as *mut libc::c_char)};
@@ -1553,6 +1369,7 @@ unsafe fn reset_shell_options () {
continue;
}
+
unsafe {
list = (*list).next; /* Skip over option name. */
}
@@ -1616,202 +1433,212 @@ unsafe fn reset_shell_options () {
}
#[no_mangle]
-pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 {
- let mut unset_function: i32 = 0;
- let mut unset_variable: i32 = 0;
- let mut unset_array: i32 = 0;
- let mut opt: i32 = 0;
- let mut nameref: i32 = 0;
- let mut any_failed: i32 = 0;
- let mut global_unset_func: i32 = 0;
- let mut global_unset_var: i32 = 0;
- let mut vflags: i32 = 0;
- let mut valid_id: i32 = 0;
- let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
- let mut tname: *mut libc::c_char = 0 as *mut libc::c_char;
-
- //println!("enter r_unset by huanhuan");
- let mut c_str_fnv = CString::new("fnv").unwrap();
- unsafe {
- reset_internal_getopt();
- opt= internal_getopt (list, c_str_fnv.as_ptr() as * mut libc::c_char);
-
- while opt != -1 {
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
- match optChar {
- 'f'=>{global_unset_func = 1;}
- 'v'=>{global_unset_var = 0;}
- 'n'=>{nameref = 1;}
- _=>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
+pub extern "C" fn r_unset_builtin(mut list: *mut WordList) -> i32 {
+ let mut unset_function: i32 = 0;
+ let mut unset_variable: i32 = 0;
+ let mut unset_array: i32 = 0;
+ let mut opt: i32 = 0;
+ let mut nameref: i32 = 0;
+ let mut any_failed: i32 = 0;
+ let mut global_unset_func: i32 = 0;
+ let mut global_unset_var: i32 = 0;
+ let mut vflags: i32 = 0;
+ let mut valid_id: i32 = 0;
+ let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
+ let mut tname: *mut libc::c_char = 0 as *mut libc::c_char;
+
+ //println!("enter r_unset by huanhuan");
+ let mut c_str_fnv = CString::new("fnv").unwrap();
+ unsafe {
+ reset_internal_getopt();
+ opt = internal_getopt(list, c_str_fnv.as_ptr() as *mut libc::c_char);
+
+ while opt != -1 {
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'f' => {
+ global_unset_func = 1;
+ }
+ 'v' => {
+ global_unset_var = 0;
+ }
+ 'n' => {
+ nameref = 1;
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
+ return EX_USAGE;
+ }
+ }
+ opt = internal_getopt(list, c_str_fnv.as_ptr() as *mut libc::c_char);
}
- builtin_usage ();
- return EX_USAGE;
+ //println!("unset func={}, unset val=%{}", global_unset_func, global_unset_var);
+
+ list = loptend;
+
+ if global_unset_func != 0 && global_unset_var != 0 {
+ builtin_error(
+ b"cannot simultaneously unset a function and a variable \0" as *const u8
+ as *const libc::c_char,
+ );
+ return EXECUTION_FAILURE!();
+ } else if unset_function != 0 && nameref != 0 {
+ nameref = 0;
}
- }
- opt =internal_getopt (list, c_str_fnv.as_ptr() as * mut libc::c_char);
- }
- //println!("unset func={}, unset val=%{}", global_unset_func, global_unset_var);
- list = loptend;
+ if assoc_expand_once != 0 {
+ vflags = VA_NOEXPAND!() | VA_ONEWORD!();
+ } else {
+ vflags = 0;
+ }
+ while !list.is_null() {
+ let mut var: *mut SHELL_VAR;
+ let mut tem: i32 = 0;
- if global_unset_func != 0 && global_unset_var != 0 {
- builtin_error (b"cannot simultaneously unset a function and a variable \0" as *const u8
- as *const libc::c_char);
- return EXECUTION_FAILURE!();
- }
- else if unset_function != 0 && nameref != 0 {
- nameref = 0;
- }
+ let mut t: *mut libc::c_char = 0 as *mut libc::c_char;
- if assoc_expand_once != 0 {
- vflags = VA_NOEXPAND!()|VA_ONEWORD!();
- }
- else {
- vflags = 0;
- }
- while !list.is_null() {
- let mut var : *mut SHELL_VAR;
- let mut tem : i32 = 0;
+ name = (*(*list).word).word;
+ unset_function = global_unset_func;
+ unset_variable = global_unset_var;
+ unset_array = 0;
- let mut t : *mut libc::c_char = 0 as *mut libc::c_char;
+ if !unset_function == 0 && nameref == 0 && valid_array_reference(name, vflags) != 0 {
+ t = libc::strchr(name, '[' as i32);
+ *t.offset(1 as isize) = b'\0' as i32 as libc::c_char;
+ unset_array = unset_array + 1;
+ }
- name = (*(*list).word).word;
- unset_function = global_unset_func;
- unset_variable = global_unset_var;
- unset_array = 0 ;
+ valid_id = legal_identifier(name);
- if !unset_function == 0 && nameref == 0 && valid_array_reference (name, vflags) != 0 {
- t = libc::strchr (name, '[' as i32);
- *t.offset(1 as isize) = b'\0' as i32 as libc::c_char;
- unset_array = unset_array + 1;
- }
+ if global_unset_func == 0 && global_unset_var == 0 && valid_id == 0 {
+ unset_array = 0;
+ unset_variable = unset_array;
+ unset_function = 1;
+ }
- valid_id = legal_identifier (name);
+ if (unset_function == 0 && valid_id == 0) {
+ sh_invalidid(name);
+ any_failed = any_failed + 1;
+ list = (*list).next;
+ }
- if global_unset_func == 0 && global_unset_var == 0 && valid_id == 0 {
- unset_array = 0;
- unset_variable = unset_array ;
- unset_function = 1;
- }
+ if unset_function != 0 {
+ var = find_function(name);
+ } else {
+ if nameref != 0 {
+ var = find_variable_last_nameref(name, 0);
+ } else {
+ var = find_variable(name);
+ }
+ }
- if (unset_function == 0 && valid_id == 0)
- {
- sh_invalidid (name);
- any_failed = any_failed + 1;
- list = (*list).next;
- }
-
- if unset_function != 0 {
- var = find_function (name);
- }
- else {
- if nameref != 0 {
- var = find_variable_last_nameref (name, 0) ;
- }
- else {
- var = find_variable (name);
- }
- }
+ if var != std::ptr::null_mut() && unset_function == 0 && non_unsettable_p!(var) != 0 {
+ builtin_error(
+ b"%s: cannot unset \0" as *const u8 as *const libc::c_char,
+ name,
+ );
+ any_failed = any_failed + 1;
+ list = (*list).next;
+ }
- if var != std::ptr::null_mut() && unset_function == 0 && non_unsettable_p!(var) != 0 {
- builtin_error (b"%s: cannot unset \0" as *const u8
- as *const libc::c_char, name);
- any_failed = any_failed + 1;
- list = (*list).next;
- }
+ if var != std::ptr::null_mut()
+ && unset_function == 0
+ && nameref == 0
+ && STREQ(name, name_cell!(var))
+ {
+ name = name_cell!(var);
+ }
- if var != std::ptr::null_mut() && unset_function == 0 && nameref == 0 && STREQ (name, name_cell!(var)) {
- name = name_cell!(var);
- }
-
- if var == std::ptr::null_mut() && nameref == 0 && unset_variable == 0 && unset_function == 0{
- var = find_function (name);
- if var != std::ptr::null_mut() {
- unset_function = 1;
- }
- }
+ if var == std::ptr::null_mut()
+ && nameref == 0
+ && unset_variable == 0
+ && unset_function == 0
+ {
+ var = find_function(name);
+ if var != std::ptr::null_mut() {
+ unset_function = 1;
+ }
+ }
- if var!= std::ptr::null_mut() && readonly_p! (var)!= 0 {
- if unset_function != 0 {
- builtin_error (b"%s: cannot unset: readonly %s \0 " as *const u8 as *mut libc::c_char,
- (*var).name, b"function\0" as *const u8 as *mut libc::c_char);
- }
- else {
- builtin_error (b"%s: cannot unset: readonly %s \0" as *const u8 as *mut libc::c_char,
- (*var).name, b"variable\0" as *const u8 as *mut libc::c_char);
- }
- any_failed = any_failed + 1;
- list = (*list).next;
- }
- // #if defined (ARRAY_VARS)
- if var != std::ptr::null_mut() && unset_array != 0 {
- /* Let unbind_array_element decide what to do with non-array vars */
- tem = unbind_array_element (var, t, vflags); /* XXX new third arg */
- if tem == -2 && array_p!(var) == 0 && assoc_p! (var) == 0 {
- builtin_error (b"%s: not an array variable\0" as *const u8
- as *const libc::c_char, (*var).name);
- any_failed = any_failed + 1;
- list = (*list).next;
- }
- else if tem < 0 {
- any_failed = any_failed + 1;
- }
- }
-
- else {
- if var == std::ptr::null_mut() && nameref == 0 && unset_function == 0 {
- var = find_variable_last_nameref (name, 0);
- if var != std::ptr::null_mut() && nameref_p!(var) != 0 {
- if valid_array_reference (nameref_cell!(var), 0) != 0 {
- tname = r_savestring(nameref_cell!(var));
- var = array_variable_part (tname, 0, &mut t, &mut 0);
- if var != std::ptr::null_mut() {
- tem = unbind_array_element (var, t, vflags); /* XXX new third arg */
+ if var != std::ptr::null_mut() && readonly_p!(var) != 0 {
+ if unset_function != 0 {
+ builtin_error(
+ b"%s: cannot unset: readonly %s \0 " as *const u8 as *mut libc::c_char,
+ (*var).name,
+ b"function\0" as *const u8 as *mut libc::c_char,
+ );
+ } else {
+ builtin_error(
+ b"%s: cannot unset: readonly %s \0" as *const u8 as *mut libc::c_char,
+ (*var).name,
+ b"variable\0" as *const u8 as *mut libc::c_char,
+ );
+ }
+ any_failed = any_failed + 1;
+ list = (*list).next;
}
- libc::free (tname as *mut libc::c_void );
- }
-
- else {
- tem = unbind_variable(nameref_cell! (var));
- }
- }
- else {
- tem = unbind_variable (name);
- }
- }
- else {
- if unset_function != 0 {
- tem = unbind_func (name);
- }
- else if nameref != 0 {
- tem = unbind_nameref (name);
- }
- else {
- tem = unbind_variable (name);
+ // #if defined (ARRAY_VARS)
+ if var != std::ptr::null_mut() && unset_array != 0 {
+ /* Let unbind_array_element decide what to do with non-array vars */
+ tem = unbind_array_element(var, t, vflags); /* XXX new third arg */
+ if tem == -2 && array_p!(var) == 0 && assoc_p!(var) == 0 {
+ builtin_error(
+ b"%s: not an array variable\0" as *const u8 as *const libc::c_char,
+ (*var).name,
+ );
+ any_failed = any_failed + 1;
+ list = (*list).next;
+ } else if tem < 0 {
+ any_failed = any_failed + 1;
+ }
+ } else {
+ if var == std::ptr::null_mut() && nameref == 0 && unset_function == 0 {
+ var = find_variable_last_nameref(name, 0);
+ if var != std::ptr::null_mut() && nameref_p!(var) != 0 {
+ if valid_array_reference(nameref_cell!(var), 0) != 0 {
+ tname = r_savestring(nameref_cell!(var));
+ var = array_variable_part(tname, 0, &mut t, &mut 0);
+ if var != std::ptr::null_mut() {
+ tem = unbind_array_element(var, t, vflags); /* XXX new third arg */
+ }
+ libc::free(tname as *mut libc::c_void);
+ } else {
+ tem = unbind_variable(nameref_cell!(var));
+ }
+ } else {
+ tem = unbind_variable(name);
+ }
+ } else {
+ if unset_function != 0 {
+ tem = unbind_func(name);
+ } else if nameref != 0 {
+ tem = unbind_nameref(name);
+ } else {
+ tem = unbind_variable(name);
+ }
+ }
+ }
+
+ if tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0 {
+ tem = unbind_func(name);
+ }
+ name = (*(*list).word).word;
+
+ if unset_function == 0 {
+ stupidly_hack_special_variables(name);
+ }
+ list = (*list).next;
}
- }
- }
-
- if tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0 {
- tem = unbind_func (name);
- }
- name = (*(*list).word).word;
- if unset_function == 0 {
- stupidly_hack_special_variables (name);
+ if any_failed != 0 {
+ return EXECUTION_FAILURE!();
+ } else {
+ return EXECUTION_SUCCESS!();
+ }
}
- list = (*list).next;
- }
-
- if any_failed != 0 {
- return EXECUTION_FAILURE!();
- }
- else {
- return EXECUTION_SUCCESS!();
- }
-}
}
diff --git a/bash-5.1/builtins_rust/setattr/src/lib.rs b/bash-5.1/builtins_rust/setattr/src/lib.rs
index 9f85d129e2a3a11fb10aa46cc53d5aa9c54bceff..07d1727c35804b4ec569ccba77b5800d8e934a33 100644
--- a/bash-5.1/builtins_rust/setattr/src/lib.rs
+++ b/bash-5.1/builtins_rust/setattr/src/lib.rs
@@ -1,9 +1,8 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use std::mem::size_of_val;
-use libc::{c_int, c_uint, c_char, c_long, PT_NULL, c_void};
+use libc::{c_char, c_int, c_long, c_uint, c_void, PT_NULL};
use rhelp::r_builtin_help;
include!(concat!("intercdep.rs"));
use std::ffi::CStr;
@@ -19,7 +18,11 @@ pub extern "C" fn r_readonly_builtin(list: *mut WordList) -> c_int {
}
#[no_mangle]
-pub extern "C" fn set_or_show_attributes(mut list: *mut WordList, mut attribute: c_int, nodefs: c_int) -> c_int {
+pub extern "C" fn set_or_show_attributes(
+ mut list: *mut WordList,
+ mut attribute: c_int,
+ nodefs: c_int,
+) -> c_int {
let mut assign_error: c_int = 0;
let mut any_failed: c_int = 0;
let mut undo: c_int = 0;
@@ -33,205 +36,214 @@ pub extern "C" fn set_or_show_attributes(mut list: *mut WordList, mut attribute:
let mut tlist: *mut WordList;
let mut nlist: *mut WordList;
let mut w: *mut WordDesc;
-unsafe {
- reset_internal_getopt();
- let opt_str = std::ffi::CString::new("aAfnp").unwrap();
- let mut opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- while opt != -1 {
- let opt_char:char=char::from(opt as u8);
- match opt_char {
- 'n' => undo = 1,
- 'f' => functions_only = true,
- 'a' => arrays_only = 1,
- 'A' => assoc_only = 1,
- 'p' => break,
- _ => {
- if opt == -99 {
- r_builtin_help();
+ unsafe {
+ reset_internal_getopt();
+ let opt_str = std::ffi::CString::new("aAfnp").unwrap();
+ let mut opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
+ while opt != -1 {
+ let opt_char: char = char::from(opt as u8);
+ match opt_char {
+ 'n' => undo = 1,
+ 'f' => functions_only = true,
+ 'a' => arrays_only = 1,
+ 'A' => assoc_only = 1,
+ 'p' => break,
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ builtin_usage();
return EX_USAGE;
}
- builtin_usage ();
- return EX_USAGE;
}
+ opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
}
- opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- }
- list = loptend;
-
- if !list.is_null() {
- if attribute & att_exported != 0 {
- array_needs_making = 1;
- }
- if undo != 0 && (attribute & att_readonly) != 0 {
- attribute &= !att_readonly;
- }
- while !list.is_null() {
- name = (*(*list).word).word;
+ list = loptend;
- if functions_only {
- var = find_function(name);
- if var.is_null() {
- builtin_error("%s: not a function\0".as_ptr() as *const c_char, name);
- any_failed += 1;
- } else if (attribute & att_exported) != 0 && undo == 0 &&
- exportable_function_name(name) == 0 {
- builtin_error("%s: cannot export\0".as_ptr() as *const c_char, name);
- any_failed += 1;
- } else {
- if undo == 0 {
- (*var).attributes |= attribute;
- } else {
- (*var).attributes &= !attribute;
+ if !list.is_null() {
+ if attribute & att_exported != 0 {
+ array_needs_making = 1;
+ }
+ if undo != 0 && (attribute & att_readonly) != 0 {
+ attribute &= !att_readonly;
+ }
+ while !list.is_null() {
+ name = (*(*list).word).word;
+
+ if functions_only {
+ var = find_function(name);
+ if var.is_null() {
+ builtin_error("%s: not a function\0".as_ptr() as *const c_char, name);
+ any_failed += 1;
+ } else if (attribute & att_exported) != 0
+ && undo == 0
+ && exportable_function_name(name) == 0
+ {
+ builtin_error("%s: cannot export\0".as_ptr() as *const c_char, name);
+ any_failed += 1;
+ } else {
+ if undo == 0 {
+ (*var).attributes |= attribute;
+ } else {
+ (*var).attributes &= !attribute;
+ }
}
+ list = (*list).next;
+ continue;
}
- list = (*list).next;
- continue;
- }
- assign = assignment(name, 0);
- aflags = 0;
- if assign != 0 {
- *(name.offset(assign as isize ) ) = b'\0' as c_char;
- if *((name.offset((assign-1) as isize))) == b'+' as c_char {
- aflags |= ASS_APPEND;
- *(name.offset((assign-1) as isize)) = b'\0' as c_char;
- }
- }
-
- if legal_identifier(name) == 0 {
- sh_invalidid(name);
+ assign = assignment(name, 0);
+ aflags = 0;
if assign != 0 {
- assign_error += 1;
- } else {
- any_failed += 1;
- }
- list = (*list).next;
- continue;
- }
-
- if assign != 0 {
- *(name.offset(assign as isize)) = b'=' as c_char;
- if (aflags & ASS_APPEND) != 0 {
- *(name.offset((assign-1) as isize)) = b'+' as c_char;
+ *(name.offset(assign as isize)) = b'\0' as c_char;
+ if *(name.offset((assign - 1) as isize)) == b'+' as c_char {
+ aflags |= ASS_APPEND;
+ *(name.offset((assign - 1) as isize)) = b'\0' as c_char;
+ }
}
- if arrays_only != 0 || assoc_only != 0 {
- tlist = (*list).next;
- (*list).next = PT_NULL as *mut WordList;
-
- let mut optw: [u8;8] = [0;8];
- optw[0] = b'-';
- optw[1] = b'g';
- let mut opti = 2;
- if (attribute & att_readonly) != 0 {
- optw[opti] = b'r';
- opti += 1;
- }
- if (attribute & att_exported) != 0 {
- optw[opti] = b'x';
- opti += 1;
- }
- if (attribute & arrays_only) != 0 {
- optw[opti] = b'a';
- opti += 1;
+ if legal_identifier(name) == 0 {
+ sh_invalidid(name);
+ if assign != 0 {
+ assign_error += 1;
} else {
- optw[opti] = b'A';
- opti += 1;
+ any_failed += 1;
}
+ list = (*list).next;
+ continue;
+ }
- w = make_word(optw.as_ptr() as *const c_char);
- nlist = make_word_list(w, list);
+ if assign != 0 {
+ *(name.offset(assign as isize)) = b'=' as c_char;
+ if (aflags & ASS_APPEND) != 0 {
+ *(name.offset((assign - 1) as isize)) = b'+' as c_char;
+ }
- opt = declare_builtin(nlist);
- if opt != EXECUTION_SUCCESS {
+ if arrays_only != 0 || assoc_only != 0 {
+ tlist = (*list).next;
+ (*list).next = PT_NULL as *mut WordList;
+
+ let mut optw: [u8; 8] = [0; 8];
+ optw[0] = b'-';
+ optw[1] = b'g';
+ let mut opti = 2;
+ if (attribute & att_readonly) != 0 {
+ optw[opti] = b'r';
+ opti += 1;
+ }
+ if (attribute & att_exported) != 0 {
+ optw[opti] = b'x';
+ opti += 1;
+ }
+ if (attribute & arrays_only) != 0 {
+ optw[opti] = b'a';
+ opti += 1;
+ } else {
+ optw[opti] = b'A';
+ opti += 1;
+ }
+
+ w = make_word(optw.as_ptr() as *const c_char);
+ nlist = make_word_list(w, list);
+
+ opt = declare_builtin(nlist);
+ if opt != EXECUTION_SUCCESS {
+ assign_error += 1;
+ }
+ (*list).next = tlist;
+ dispose_word(w);
+ libc::free(nlist as *mut c_void);
+ } else if do_assignment_no_expand(name) == 0 {
assign_error += 1;
}
- (*list).next = tlist;
- dispose_word(w);
- libc::free(nlist as *mut c_void);
- } else if do_assignment_no_expand(name) == 0 {
- assign_error += 1;
- }
- *(name.offset(assign as isize)) = b'\0' as c_char;
- if (aflags & ASS_APPEND) != 0 {
- *(name.offset((assign-1) as isize)) = b'\0' as c_char;
+ *(name.offset(assign as isize)) = b'\0' as c_char;
+ if (aflags & ASS_APPEND) != 0 {
+ *(name.offset((assign - 1) as isize)) = b'\0' as c_char;
+ }
}
- }
- set_var_attribute(name, attribute, undo);
- if assign != 0 {
- *(name.offset(assign as isize)) = b'=' as c_char;
- // *((name as usize + assign as usize) as *mut c_char) = b'=' as c_char;
- if (aflags & ASS_APPEND) != 0 {
- *(name.offset((assign-1) as isize)) = b'+' as c_char;
+ set_var_attribute(name, attribute, undo);
+ if assign != 0 {
+ *(name.offset(assign as isize)) = b'=' as c_char;
+ // *((name as usize + assign as usize) as *mut c_char) = b'=' as c_char;
+ if (aflags & ASS_APPEND) != 0 {
+ *(name.offset((assign - 1) as isize)) = b'+' as c_char;
+ }
}
- }
- list = (*list).next;
- }
- } else {
- let mut variable_list: *mut *mut SHELL_VAR;
- if (attribute & att_function) != 0 || functions_only {
- variable_list = all_shell_functions();
- if attribute != att_function {
- attribute &= !att_function;
+ list = (*list).next;
}
} else {
- variable_list = all_shell_variables();
- }
-
- if (attribute & att_array) != 0 {
- arrays_only += 1;
- if attribute != att_array {
- attribute &= !att_array;
- }
- } else if (attribute & att_assoc) != 0 {
- assoc_only += 1;
- if attribute != att_assoc {
- attribute &= !att_assoc;
+ let variable_list: *mut *mut SHELL_VAR;
+ if (attribute & att_function) != 0 || functions_only {
+ variable_list = all_shell_functions();
+ if attribute != att_function {
+ attribute &= !att_function;
+ }
+ } else {
+ variable_list = all_shell_variables();
}
- }
- if !variable_list.is_null() {
- let mut i = 0;
- loop {
- var = *(variable_list.offset(i)) as *mut SHELL_VAR;
- if var.is_null() {
- break;
+ if (attribute & att_array) != 0 {
+ arrays_only += 1;
+ if attribute != att_array {
+ attribute &= !att_array;
}
-
- if arrays_only != 0 && (((*var).attributes & att_array) == 0) {
- i += 1;
- continue;
- } else if assoc_only != 0 && (((*var).attributes & att_assoc) == 0) {
- i += 1;
- continue;
+ } else if (attribute & att_assoc) != 0 {
+ assoc_only += 1;
+ if attribute != att_assoc {
+ attribute &= !att_assoc;
}
+ }
- if ((*var).attributes & (att_invisible | att_exported)) == (att_invisible | att_exported) {
- i += 1;
- continue;
- }
+ if !variable_list.is_null() {
+ let mut i = 0;
+ loop {
+ var = *(variable_list.offset(i)) as *mut SHELL_VAR;
+ if var.is_null() {
+ break;
+ }
- if ((*var).attributes & attribute) != 0 {
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
- if pattr {
- show_var_attributes(var, 1, nodefs);
+ if arrays_only != 0 && (((*var).attributes & att_array) == 0) {
+ i += 1;
+ continue;
+ } else if assoc_only != 0 && (((*var).attributes & att_assoc) == 0) {
+ i += 1;
+ continue;
}
- else {
- show_var_attributes(var, 0, nodefs);
+
+ if ((*var).attributes & (att_invisible | att_exported))
+ == (att_invisible | att_exported)
+ {
+ i += 1;
+ continue;
}
- any_failed = sh_chkwrite(any_failed);
- if any_failed != 0 {
- break;
+
+ if ((*var).attributes & attribute) != 0 {
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
+ if pattr {
+ show_var_attributes(var, 1, nodefs);
+ } else {
+ show_var_attributes(var, 0, nodefs);
+ }
+ any_failed = sh_chkwrite(any_failed);
+ if any_failed != 0 {
+ break;
+ }
}
+ i += 1;
}
- i += 1;
+ libc::free(variable_list as *mut c_void);
}
- libc::free(variable_list as *mut c_void);
}
}
-}
- return if assign_error != 0 {EX_BADASSIGN} else if any_failed == 0 {EXECUTION_SUCCESS} else {EXECUTION_FAILURE};
+ return if assign_error != 0 {
+ EX_BADASSIGN
+ } else if any_failed == 0 {
+ EXECUTION_SUCCESS
+ } else {
+ EXECUTION_FAILURE
+ };
}
#[no_mangle]
@@ -239,83 +251,109 @@ pub extern "C" fn show_all_var_attributes(v: c_int, nodefs: c_int) -> c_int {
let mut i = 0;
let mut any_failed = 0;
let mut var: *mut SHELL_VAR;
- let mut variable_list: *mut *mut SHELL_VAR;
-unsafe {
- variable_list = if v != 0 {all_shell_variables() } else {all_shell_functions()};
- if variable_list.is_null() {
- return EXECUTION_SUCCESS;
- }
-
- loop {
- var = *(variable_list.offset(i));
- if var.is_null() {
- break;
- }
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
- if pattr {
- show_var_attributes(var, 1, nodefs);
- }
- else {
- show_var_attributes(var, 0, nodefs);
+ let variable_list: *mut *mut SHELL_VAR;
+ unsafe {
+ variable_list = if v != 0 {
+ all_shell_variables()
+ } else {
+ all_shell_functions()
+ };
+ if variable_list.is_null() {
+ return EXECUTION_SUCCESS;
}
- any_failed = sh_chkwrite(any_failed);
- if any_failed != 0 {
- break;
+
+ loop {
+ var = *(variable_list.offset(i));
+ if var.is_null() {
+ break;
+ }
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
+ if pattr {
+ show_var_attributes(var, 1, nodefs);
+ } else {
+ show_var_attributes(var, 0, nodefs);
+ }
+ any_failed = sh_chkwrite(any_failed);
+ if any_failed != 0 {
+ break;
+ }
+ i += 1;
}
- i += 1;
- }
- libc::free(variable_list as *mut c_void);
-}
- return if any_failed == 0 {EXECUTION_SUCCESS} else {EXECUTION_FAILURE};
+ libc::free(variable_list as *mut c_void);
+ }
+ return if any_failed == 0 {
+ EXECUTION_SUCCESS
+ } else {
+ EXECUTION_FAILURE
+ };
}
#[no_mangle]
-pub extern "C" fn show_local_var_attributes(v: c_int, nodefs: c_int) -> c_int {
+pub extern "C" fn show_local_var_attributes(_v: c_int, nodefs: c_int) -> c_int {
let mut i = 0;
let mut any_failed = 0;
let mut var: *mut SHELL_VAR;
- let mut variable_list: *mut *mut SHELL_VAR;
-unsafe {
- variable_list = all_local_variables(0);
- if variable_list.is_null() {
- return EXECUTION_SUCCESS;
- }
-
- loop {
- var = variable_list.offset(i) as *mut SHELL_VAR;
- if var.is_null() {
- break;
+ let variable_list: *mut *mut SHELL_VAR;
+ unsafe {
+ variable_list = all_local_variables(0);
+ if variable_list.is_null() {
+ return EXECUTION_SUCCESS;
}
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
- if pattr {
- show_var_attributes(var, 1, nodefs);
- }
- else {
- show_var_attributes(var, 0, nodefs);
- }
- any_failed = sh_chkwrite(any_failed);
- if any_failed != 0 {
- break;
+ loop {
+ var = variable_list.offset(i) as *mut SHELL_VAR;
+ if var.is_null() {
+ break;
+ }
+
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
+ if pattr {
+ show_var_attributes(var, 1, nodefs);
+ } else {
+ show_var_attributes(var, 0, nodefs);
+ }
+ any_failed = sh_chkwrite(any_failed);
+ if any_failed != 0 {
+ break;
+ }
+
+ i += 1;
}
- i += 1;
+ libc::free(variable_list as *mut c_void);
}
-
- libc::free(variable_list as *mut c_void);
-}
- return if any_failed == 0 {EXECUTION_SUCCESS} else {EXECUTION_FAILURE};
+ return if any_failed == 0 {
+ EXECUTION_SUCCESS
+ } else {
+ EXECUTION_FAILURE
+ };
}
#[no_mangle]
-pub unsafe extern "C" fn show_var_attributes(var: *mut SHELL_VAR, pattr: c_int, mut nodefs: c_int) -> c_int {
- let mut flags = [0;16];
+pub unsafe extern "C" fn show_var_attributes(
+ var: *mut SHELL_VAR,
+ pattr: c_int,
+ mut nodefs: c_int,
+) -> c_int {
+ let mut flags = [0; 16];
let i = var_attribute_string(var, pattr, flags.as_mut_ptr());
- if ((*var).attributes & att_function) != 0 && nodefs == 0 && (pattr == 0 || posixly_correct == 0) {
- println!("{}",CStr::from_ptr(named_function_string((*var).name, (*var).value as *mut COMMAND, FUNC_MULTILINE | FUNC_EXTERNAL)).to_str().unwrap());
+ if ((*var).attributes & att_function) != 0
+ && nodefs == 0
+ && (pattr == 0 || posixly_correct == 0)
+ {
+ println!(
+ "{}",
+ CStr::from_ptr(named_function_string(
+ (*var).name,
+ (*var).value as *mut COMMAND,
+ FUNC_MULTILINE | FUNC_EXTERNAL
+ ))
+ .to_str()
+ .unwrap()
+ );
nodefs += 1;
if pattr == 0 && i == 1 && flags[0] == b'f' as c_char {
return 0;
@@ -323,115 +361,124 @@ pub unsafe extern "C" fn show_var_attributes(var: *mut SHELL_VAR, pattr: c_int
}
if pattr == 0 || posixly_correct == 0 {
if i != 0 {
- print!("declare -{} ",CStr::from_ptr(flags.as_ptr()).to_str().unwrap());
- }
- else {
+ print!(
+ "declare -{} ",
+ CStr::from_ptr(flags.as_ptr()).to_str().unwrap()
+ );
+ } else {
print!("declare -- ");
}
- }
- else if i != 0 {
- print!("{} -{} ",CStr::from_ptr(this_command_name).to_str().unwrap(),CStr::from_ptr(flags.as_ptr()).to_str().unwrap());
- }
- else {
- print!("{} ",CStr::from_ptr(this_command_name).to_str().unwrap());
+ } else if i != 0 {
+ print!(
+ "{} -{} ",
+ CStr::from_ptr(this_command_name).to_str().unwrap(),
+ CStr::from_ptr(flags.as_ptr()).to_str().unwrap()
+ );
+ } else {
+ print!("{} ", CStr::from_ptr(this_command_name).to_str().unwrap());
}
- if ((*var).attributes & att_invisible) != 0 &&
- (((*var).attributes & att_array) != 0 ||
- ((*var).attributes & att_assoc) != 0 ){
- println!("{}",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- else if ((*var).attributes & att_array) != 0 {
+ if ((*var).attributes & att_invisible) != 0
+ && (((*var).attributes & att_array) != 0 || ((*var).attributes & att_assoc) != 0)
+ {
+ println!("{}", CStr::from_ptr((*var).name).to_str().unwrap());
+ } else if ((*var).attributes & att_array) != 0 {
r_print_array_assignment(var, 0);
- }
- else if ((*var).attributes & att_assoc) != 0 {
+ } else if ((*var).attributes & att_assoc) != 0 {
r_print_assoc_assignment(var, 0);
- }
- else if nodefs != 0 || ((((*var).attributes & att_function) != 0 && pattr != 0 && posixly_correct != 0)) {
- println!("{}",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- else if ((*var).attributes & att_function) != 0 {
- println!("{}",CStr::from_ptr(named_function_string((*var).name, (*var).value as *mut COMMAND, FUNC_MULTILINE | FUNC_EXTERNAL)).to_str().unwrap());
- }
- else if ((*var).attributes & att_invisible) != 0 || (*var).value == std::ptr::null_mut() {
- println!("{}",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- else {
- let x = sh_double_quote (value_cell(var));
- println!("{}={}",CStr::from_ptr((*var).name).to_str().unwrap(),CStr::from_ptr(x).to_str().unwrap());
- libc::free(x as *mut c_void);
+ } else if nodefs != 0
+ || (((*var).attributes & att_function) != 0 && pattr != 0 && posixly_correct != 0)
+ {
+ println!("{}", CStr::from_ptr((*var).name).to_str().unwrap());
+ } else if ((*var).attributes & att_function) != 0 {
+ println!(
+ "{}",
+ CStr::from_ptr(named_function_string(
+ (*var).name,
+ (*var).value as *mut COMMAND,
+ FUNC_MULTILINE | FUNC_EXTERNAL
+ ))
+ .to_str()
+ .unwrap()
+ );
+ } else if ((*var).attributes & att_invisible) != 0 || (*var).value == std::ptr::null_mut() {
+ println!("{}", CStr::from_ptr((*var).name).to_str().unwrap());
+ } else {
+ let x = sh_double_quote(value_cell(var));
+ println!(
+ "{}={}",
+ CStr::from_ptr((*var).name).to_str().unwrap(),
+ CStr::from_ptr(x).to_str().unwrap()
+ );
+ libc::free(x as *mut c_void);
}
return 0;
}
-unsafe fn value_cell(var:*mut SHELL_VAR)->* mut c_char
-{
- return (*var).value;
+unsafe fn value_cell(var: *mut SHELL_VAR) -> *mut c_char {
+ return (*var).value;
}
-unsafe fn array_cell(var:*mut SHELL_VAR)->* mut ARRAY
-{
- return (*var).value as *mut ARRAY;
+unsafe fn array_cell(var: *mut SHELL_VAR) -> *mut ARRAY {
+ return (*var).value as *mut ARRAY;
}
-unsafe fn assoc_cell(var:*mut SHELL_VAR)->* mut HASH_TABLE
-{
- return (*var).value as *mut HASH_TABLE;
+unsafe fn assoc_cell(var: *mut SHELL_VAR) -> *mut HASH_TABLE {
+ return (*var).value as *mut HASH_TABLE;
}
#[no_mangle]
pub extern "C" fn show_name_attributes(name: *mut c_char, nodefs: c_int) -> c_int {
-unsafe {
- let var = find_variable_noref(name);
- if !var.is_null() {
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
- if pattr {
- show_var_attributes(var, 1, nodefs);
- }
- else {
- show_var_attributes(var, 0, nodefs);
+ unsafe {
+ let var = find_variable_noref(name);
+ if !var.is_null() {
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
+ if pattr {
+ show_var_attributes(var, 1, nodefs);
+ } else {
+ show_var_attributes(var, 0, nodefs);
+ }
+ return 0;
+ } else {
+ return 1;
}
- return 0;
- } else {
- return 1;
}
}
-}
#[no_mangle]
pub extern "C" fn show_localname_attributes(name: *mut c_char, nodefs: c_int) -> c_int {
-unsafe {
- let var = find_variable_noref(name);
- let cond = var.is_null() && ((*var).attributes & att_local) != 0 && (*var).context == variable_context;
- if cond {
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
- if pattr {
- show_var_attributes(var, 1, nodefs);
- }
- else {
- show_var_attributes(var, 0, nodefs);
+ unsafe {
+ let var = find_variable_noref(name);
+ let cond = var.is_null()
+ && ((*var).attributes & att_local) != 0
+ && (*var).context == variable_context;
+ if cond {
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
+ if pattr {
+ show_var_attributes(var, 1, nodefs);
+ } else {
+ show_var_attributes(var, 0, nodefs);
+ }
+ return 0;
+ } else {
+ return 1;
}
- return 0;
- } else {
- return 1;
}
}
-}
#[no_mangle]
pub extern "C" fn show_func_attributes(name: *mut c_char, nodefs: c_int) -> c_int {
unsafe {
let var = find_function(name);
if !var.is_null() {
- let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize) ||
- (this_shell_builtin as usize == r_export_builtin as usize);
+ let pattr = (this_shell_builtin as usize == r_readonly_builtin as usize)
+ || (this_shell_builtin as usize == r_export_builtin as usize);
if pattr {
show_var_attributes(var, 1, nodefs);
- }
- else {
+ } else {
show_var_attributes(var, 0, nodefs);
}
return 0;
@@ -444,145 +491,156 @@ pub extern "C" fn show_func_attributes(name: *mut c_char, nodefs: c_int) -> c_in
#[no_mangle]
pub extern "C" fn set_var_attribute(name: *mut c_char, attribute: c_int, undo: c_int) {
let mut var: *mut SHELL_VAR;
- let mut tvalue: *mut c_char;
-unsafe {
- if undo != 0 {
- var = find_variable(name);
- } else {
- let tv = find_tempenv_variable(name);
- if !tv.is_null() && ((*tv).attributes & att_tempvar) != 0 {
- tvalue = if !(*tv).value.is_null() {
- libc::strdup((*tv).value)
- } else {"\0".as_ptr() as *mut c_char};
+ let tvalue: *mut c_char;
+ unsafe {
+ if undo != 0 {
+ var = find_variable(name);
+ } else {
+ let tv = find_tempenv_variable(name);
+ if !tv.is_null() && ((*tv).attributes & att_tempvar) != 0 {
+ tvalue = if !(*tv).value.is_null() {
+ libc::strdup((*tv).value)
+ } else {
+ "\0".as_ptr() as *mut c_char
+ };
- var = bind_variable((*tv).name, tvalue, 0);
- if var.is_null() {
- libc::free(tvalue as *mut c_void);
- return;
- }
- (*var).attributes |= (*tv).attributes & (!att_tempvar);
- if posixly_correct != 0 || shell_compatibility_level <= 44 {
- if (*var).context == 0 && (attribute & att_readonly) != 0 {
- let v = find_global_variable((*tv).name);
- if v as usize != var as usize {
+ var = bind_variable((*tv).name, tvalue, 0);
+ if var.is_null() {
+ libc::free(tvalue as *mut c_void);
+ return;
+ }
+ (*var).attributes |= (*tv).attributes & (!att_tempvar);
+ if posixly_correct != 0 || shell_compatibility_level <= 44 {
+ if (*var).context == 0 && (attribute & att_readonly) != 0 {
+ let v = find_global_variable((*tv).name);
+ if v as usize != var as usize {
+ (*tv).attributes |= att_propagate;
+ }
+ } else {
(*tv).attributes |= att_propagate;
}
+
+ if (*var).context != 0 {
+ (*var).attributes |= att_propagate;
+ }
+ }
+ if undo == 0 {
+ (*tv).attributes |= attribute;
} else {
- (*tv).attributes |= att_propagate;
+ (*tv).attributes &= !attribute;
}
- if (*var).context != 0 {
+ stupidly_hack_special_variables((*tv).name);
+ libc::free(tvalue as *mut c_void);
+ } else {
+ var = find_variable_notempenv(name);
+ if var.is_null() {
+ let refvar = find_variable_nameref_for_create(name, 0);
+ if cmp_two(
+ std::mem::transmute(refvar),
+ std::mem::transmute(&nameref_invalid_value),
+ ) {
+ return;
+ }
+ }
+ if var.is_null() {
+ var = bind_variable(name, PT_NULL as *mut c_char, 0);
+ if !var.is_null() {
+ (*var).attributes |= att_invisible;
+ }
+ } else if (*var).context != 0 {
(*var).attributes |= att_propagate;
}
}
+ }
+
+ if !var.is_null() {
if undo == 0 {
- (*tv).attributes |= attribute;
+ (*var).attributes |= attribute;
} else {
- (*tv).attributes &= !attribute;
- }
-
- stupidly_hack_special_variables((*tv).name);
- libc::free(tvalue as *mut c_void);
- } else {
- var = find_variable_notempenv(name);
- if var.is_null() {
- let refvar = find_variable_nameref_for_create(name, 0);
- if cmp_two(std::mem::transmute(refvar),std::mem::transmute(&nameref_invalid_value)) {
- return;
- }
- }
- if var.is_null() {
- var = bind_variable(name, PT_NULL as *mut c_char, 0);
- if !var.is_null() {
- (*var).attributes |= att_invisible;
- }
- } else if (*var).context != 0 {
- (*var).attributes |= att_propagate;
+ (*var).attributes &= !attribute;
}
}
- }
- if !var.is_null() {
- if undo == 0 {
- (*var).attributes |= attribute;
- } else {
- (*var).attributes &= !attribute;
+ if !var.is_null()
+ && (((*var).attributes & att_exported) != 0 || (attribute & att_exported) != 0)
+ {
+ array_needs_making += 1;
}
}
-
- if !var.is_null() && (((*var).attributes & att_exported) != 0 || (attribute & att_exported) != 0) {
- array_needs_making += 1;
- }
-}
}
#[no_mangle]
-pub extern "C" fn var_attribute_string(var: *mut SHELL_VAR, pattr: c_int, flags: *mut c_char) -> c_int {
+pub extern "C" fn var_attribute_string(
+ var: *mut SHELL_VAR,
+ pattr: c_int,
+ flags: *mut c_char,
+) -> c_int {
let mut i = 0;
-unsafe {
- if pattr == 0 || posixly_correct == 0 {
- if ((*var).attributes & att_array) != 0 {
- *(flags.offset(i as isize)) = b'a' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_assoc) != 0 {
- *(flags.offset(i as isize)) = b'A' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_function) != 0 {
- *(flags.offset(i as isize)) = b'f' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_integer) != 0 {
- *(flags.offset(i as isize)) = b'i' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_nameref) != 0 {
- *(flags.offset(i as isize)) = b'n' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_readonly) != 0 {
- *(flags.offset(i as isize)) = b'r' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_trace) != 0 {
- *(flags.offset(i as isize)) = b't' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_exported) != 0 {
- *(flags.offset(i as isize)) = b'x' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_capcase) != 0 {
- *(flags.offset(i as isize)) = b'c' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_lowercase) != 0 {
- *(flags.offset(i as isize)) = b'l' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_uppercase) != 0 {
- *(flags.offset(i as isize)) = b'u' as c_char;
- i += 1;
- }
- } else {
- if ((*var).attributes & att_array) != 0 {
- *(flags.offset(i as isize)) = b'a' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_assoc) != 0 {
- *(flags.offset(i as isize)) = b'A' as c_char;
- i += 1;
- }
- if ((*var).attributes & att_function) != 0 {
- *(flags.offset(i as isize)) = b'f' as c_char;
- i += 1;
+ unsafe {
+ if pattr == 0 || posixly_correct == 0 {
+ if ((*var).attributes & att_array) != 0 {
+ *(flags.offset(i as isize)) = b'a' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_assoc) != 0 {
+ *(flags.offset(i as isize)) = b'A' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_function) != 0 {
+ *(flags.offset(i as isize)) = b'f' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_integer) != 0 {
+ *(flags.offset(i as isize)) = b'i' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_nameref) != 0 {
+ *(flags.offset(i as isize)) = b'n' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_readonly) != 0 {
+ *(flags.offset(i as isize)) = b'r' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_trace) != 0 {
+ *(flags.offset(i as isize)) = b't' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_exported) != 0 {
+ *(flags.offset(i as isize)) = b'x' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_capcase) != 0 {
+ *(flags.offset(i as isize)) = b'c' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_lowercase) != 0 {
+ *(flags.offset(i as isize)) = b'l' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_uppercase) != 0 {
+ *(flags.offset(i as isize)) = b'u' as c_char;
+ i += 1;
+ }
+ } else {
+ if ((*var).attributes & att_array) != 0 {
+ *(flags.offset(i as isize)) = b'a' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_assoc) != 0 {
+ *(flags.offset(i as isize)) = b'A' as c_char;
+ i += 1;
+ }
+ if ((*var).attributes & att_function) != 0 {
+ *(flags.offset(i as isize)) = b'f' as c_char;
+ i += 1;
+ }
}
- }
- *(flags.offset(i as isize)) = b'\0' as c_char;
-}
- return i ;
+ *(flags.offset(i as isize)) = b'\0' as c_char;
+ }
+ return i;
}
unsafe fn cmp_two(a: usize, b: usize) -> bool {
@@ -591,36 +649,40 @@ unsafe fn cmp_two(a: usize, b: usize) -> bool {
#[no_mangle]
pub unsafe extern "C" fn r_print_array_assignment(var: *mut SHELL_VAR, quote: c_int) {
- let mut vstr = array_to_assign(array_cell(var) as *mut ARRAY ,quote);
+ let vstr = array_to_assign(array_cell(var) as *mut ARRAY, quote);
- if vstr == std::ptr::null_mut() {
+ if vstr == std::ptr::null_mut() {
if quote != 0 {
- println!("{}=\'()\'",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- else {
- println!("{}=()",CStr::from_ptr((*var).name).to_str().unwrap());
+ println!("{}=\'()\'", CStr::from_ptr((*var).name).to_str().unwrap());
+ } else {
+ println!("{}=()", CStr::from_ptr((*var).name).to_str().unwrap());
}
- }
- else {
- println!("{}={}",CStr::from_ptr((*var).name).to_str().unwrap(),CStr::from_ptr(vstr).to_str().unwrap());
+ } else {
+ println!(
+ "{}={}",
+ CStr::from_ptr((*var).name).to_str().unwrap(),
+ CStr::from_ptr(vstr).to_str().unwrap()
+ );
libc::free(vstr as *mut c_void);
}
}
#[no_mangle]
pub unsafe extern "C" fn r_print_assoc_assignment(var: *mut SHELL_VAR, quote: c_int) {
- let mut vstr = assoc_to_assign(assoc_cell(var) as *mut HASH_TABLE ,quote);
+ let vstr = assoc_to_assign(assoc_cell(var) as *mut HASH_TABLE, quote);
- if vstr == std::ptr::null_mut() {
+ if vstr == std::ptr::null_mut() {
if quote != 0 {
- println!("{}=\'()\'",CStr::from_ptr((*var).name).to_str().unwrap());
- }
- else {
- println!("{}=()",CStr::from_ptr((*var).name).to_str().unwrap());
+ println!("{}=\'()\'", CStr::from_ptr((*var).name).to_str().unwrap());
+ } else {
+ println!("{}=()", CStr::from_ptr((*var).name).to_str().unwrap());
}
- }
- else {
- println!("{}={}",CStr::from_ptr((*var).name).to_str().unwrap(),CStr::from_ptr(vstr).to_str().unwrap());
+ } else {
+ println!(
+ "{}={}",
+ CStr::from_ptr((*var).name).to_str().unwrap(),
+ CStr::from_ptr(vstr).to_str().unwrap()
+ );
libc::free(vstr as *mut c_void);
}
}
diff --git a/bash-5.1/builtins_rust/shift/src/lib.rs b/bash-5.1/builtins_rust/shift/src/lib.rs
index 8622e4ee0381263a973cc06e9053f60b4eb717e1..1004ff9f149c22b0803eb04386f46af94dec8272 100644
--- a/bash-5.1/builtins_rust/shift/src/lib.rs
+++ b/bash-5.1/builtins_rust/shift/src/lib.rs
@@ -1,8 +1,8 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char, c_long, PT_NULL};
-use rcommon::{r_sh_erange,};
+use libc::{c_char, c_int, c_long, PT_NULL};
+use rcommon::r_sh_erange;
use rhelp::r_builtin_help;
include!(concat!("intercdep.rs"));
@@ -11,41 +11,50 @@ pub static print_shift_error: c_int = 0;
#[no_mangle]
pub extern "C" fn r_shift_builtin(list: *mut WordList) -> i32 {
+ unsafe {
+ if !list.is_null()
+ && !(*list).word.is_null()
+ && libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
-unsafe {
- if !list.is_null() && !(*list).word.is_null() &&
- libc::strcmp((*((*list).word)).word, "--help\0".as_ptr() as *const c_char) == 0 {
- r_builtin_help ();
- return EX_USAGE;
- }
-
- let mut times: c_int = 0;
- if get_numeric_arg(list, 0, std::mem::transmute(×)) == 0 {
- return EXECUTION_FAILURE;
- }
+ let times: c_int = 0;
+ if get_numeric_arg(list, 0, std::mem::transmute(×)) == 0 {
+ return EXECUTION_FAILURE;
+ }
- if times == 0 {
- return EXECUTION_SUCCESS;
- } else if times < 0 {
- let s = if list.is_null() {PT_NULL as *mut c_char} else {(*(*list).word).word};
- r_sh_erange(s,"shift count\0".as_ptr() as *mut c_char);
- return EXECUTION_FAILURE;
- }
+ if times == 0 {
+ return EXECUTION_SUCCESS;
+ } else if times < 0 {
+ let s = if list.is_null() {
+ PT_NULL as *mut c_char
+ } else {
+ (*(*list).word).word
+ };
+ r_sh_erange(s, "shift count\0".as_ptr() as *mut c_char);
+ return EXECUTION_FAILURE;
+ }
- let nargs = number_of_args();
- if times > nargs {
- if print_shift_error != 0 {
- let s = if list.is_null() {PT_NULL as *mut c_char} else {(*(*list).word).word};
- r_sh_erange(s,"shift count\0".as_ptr() as *mut c_char);
+ let nargs = number_of_args();
+ if times > nargs {
+ if print_shift_error != 0 {
+ let s = if list.is_null() {
+ PT_NULL as *mut c_char
+ } else {
+ (*(*list).word).word
+ };
+ r_sh_erange(s, "shift count\0".as_ptr() as *mut c_char);
+ }
+ return EXECUTION_FAILURE;
+ } else if times == nargs {
+ clear_dollar_vars();
+ } else {
+ shift_args(times);
}
- return EXECUTION_FAILURE;
- } else if times == nargs {
- clear_dollar_vars();
- } else {
- shift_args(times);
- }
- invalidate_cached_quoted_dollar_at();
-}
+ invalidate_cached_quoted_dollar_at();
+ }
return EXECUTION_SUCCESS;
}
diff --git a/bash-5.1/builtins_rust/shopt/src/lib.rs b/bash-5.1/builtins_rust/shopt/src/lib.rs
index 12734e366c01064dfb4f19b6a504bb6e43a76cd0..5358432d1e11b03fa4544e8a8982bf6957001339 100644
--- a/bash-5.1/builtins_rust/shopt/src/lib.rs
+++ b/bash-5.1/builtins_rust/shopt/src/lib.rs
@@ -2,11 +2,11 @@
//# SPDX-License-Identifier: GPL-3.0-or-later
extern crate rcommon;
-use std::ffi::*;
-use rset::r_set_shellopts;
use libc::*;
+use rset::r_set_shellopts;
+use std::ffi::*;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage};
+use rcommon::{WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
/*
/* First, the user-visible attributes */
@@ -45,39 +45,47 @@ use rhelp::r_builtin_help;
#define attmask_scope 0x0f00000
*/
-pub static att_exported:i32= 0x0000001; /* export to environment */
-pub static att_readonly:i32= 0x0000002; /* cannot change */
-pub static att_array:i32= 0x0000004; /* value is an array */
-pub static att_function:i32= 0x0000008; /* value is a function */
-pub static att_integer:i32= 0x0000010; /* internal representation is int */
-pub static att_local:i32= 0x0000020; /* variable is local to a function */
-pub static att_assoc:i32= 0x0000040; /* variable is an associative array */
-pub static att_trace:i32= 0x0000080; /* function is traced with DEBUG trap */
-pub static att_uppercase:i32= 0x0000100; /* word converted to uppercase on assignment */
-pub static att_lowercase:i32= 0x0000200; /* word converted to lowercase on assignment */
-pub static att_capcase:i32= 0x0000400; /* word capitalized on assignment */
-pub static att_nameref:i32= 0x0000800; /* word is a name reference */
+pub static att_exported: i32 = 0x0000001; /* export to environment */
+pub static att_readonly: i32 = 0x0000002; /* cannot change */
+pub static att_array: i32 = 0x0000004; /* value is an array */
+pub static att_function: i32 = 0x0000008; /* value is a function */
+pub static att_integer: i32 = 0x0000010; /* internal representation is int */
+pub static att_local: i32 = 0x0000020; /* variable is local to a function */
+pub static att_assoc: i32 = 0x0000040; /* variable is an associative array */
+pub static att_trace: i32 = 0x0000080; /* function is traced with DEBUG trap */
+pub static att_uppercase: i32 = 0x0000100; /* word converted to uppercase on assignment */
+pub static att_lowercase: i32 = 0x0000200; /* word converted to lowercase on assignment */
+pub static att_capcase: i32 = 0x0000400; /* word capitalized on assignment */
+pub static att_nameref: i32 = 0x0000800; /* word is a name reference */
-pub static user_attrs:i32=att_exported|att_readonly|att_integer|att_local|att_trace|att_uppercase|att_lowercase|att_capcase|att_nameref;
+pub static user_attrs: i32 = att_exported
+ | att_readonly
+ | att_integer
+ | att_local
+ | att_trace
+ | att_uppercase
+ | att_lowercase
+ | att_capcase
+ | att_nameref;
-pub static attmask_user:i32= 0x0000fff;
+pub static attmask_user: i32 = 0x0000fff;
/* Internal attributes used for bookkeeping */
-pub static att_invisible:i32= 0x0001000; /* cannot see */
-pub static att_nounset:i32= 0x0002000; /* cannot unset */
-pub static att_noassign:i32= 0x0004000; /* assignment not allowed */
-pub static att_imported:i32= 0x0008000; /* came from environment */
-pub static att_special:i32= 0x0010000; /* requires special handling */
-pub static att_nofree:i32= 0x0020000; /* do not free value on unset */
-pub static att_regenerate:i32= 0x0040000; /* regenerate when exported */
+pub static att_invisible: i32 = 0x0001000; /* cannot see */
+pub static att_nounset: i32 = 0x0002000; /* cannot unset */
+pub static att_noassign: i32 = 0x0004000; /* assignment not allowed */
+pub static att_imported: i32 = 0x0008000; /* came from environment */
+pub static att_special: i32 = 0x0010000; /* requires special handling */
+pub static att_nofree: i32 = 0x0020000; /* do not free value on unset */
+pub static att_regenerate: i32 = 0x0040000; /* regenerate when exported */
-pub static attmask_int:i32= 0x00ff000;
+pub static attmask_int: i32 = 0x00ff000;
/* Internal attributes used for variable scoping. */
-pub static att_tempvar:i32=0x0100000; /* variable came from the temp environment */
-pub static att_propagate:i32= 0x0200000; /* propagate to previous scope */
+pub static att_tempvar: i32 = 0x0100000; /* variable came from the temp environment */
+pub static att_propagate: i32 = 0x0200000; /* propagate to previous scope */
-pub static attmask_scope:i32= 0x0f00000;
+pub static attmask_scope: i32 = 0x0f00000;
extern "C" {
fn printf(_: *const libc::c_char, _: ...) -> i32;
fn dcgettext(
@@ -90,17 +98,10 @@ extern "C" {
fn strlen(_: *const libc::c_char) -> libc::c_ulong;
fn free(__ptr: *mut libc::c_void);
fn xmalloc(_: SizeT) -> *mut libc::c_void;
- fn extract_colon_unit(
- _: *mut libc::c_char,
- _: *mut i32,
- ) -> *mut libc::c_char;
+ fn extract_colon_unit(_: *mut libc::c_char, _: *mut i32) -> *mut libc::c_char;
static mut localvar_inherit: i32;
fn find_variable(_: *const libc::c_char) -> *mut ShellVar;
- fn bind_variable(
- _: *const libc::c_char,
- _: *mut libc::c_char,
- _: i32,
- ) -> *mut ShellVar;
+ fn bind_variable(_: *const libc::c_char, _: *mut libc::c_char, _: i32) -> *mut ShellVar;
fn init_bash_argv();
static mut assoc_expand_once: i32;
fn dispose_words(_: *mut WordList);
@@ -182,8 +183,8 @@ pub struct variable {
pub name: *mut libc::c_char,
pub value: *mut libc::c_char,
pub exportstr: *mut libc::c_char,
- pub dynamic_value: Option::,
- pub assign_func: Option::,
+ pub dynamic_value: Option,
+ pub assign_func: Option,
pub attributes: i32,
pub context: i32,
}
@@ -200,12 +201,9 @@ pub type ShellVar = variable;
pub struct RShoptVars {
pub name: *mut libc::c_char,
pub value: *mut i32,
- pub set_func: Option::,
+ pub set_func: Option,
}
-pub type ShoptSetFuncT = unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
-) -> i32;
+pub type ShoptSetFuncT = unsafe extern "C" fn(*mut libc::c_char, i32) -> i32;
static mut SHOPT_LOGIN_SHELL: i32 = 0;
static mut SHOPT_COMPAT31: i32 = 0;
static mut SHOPT_COMPAT32: i32 = 0;
@@ -218,13 +216,11 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
[
{
let init = RShoptVars {
- name: b"autocd\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"autocd\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &autocd as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -233,187 +229,138 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
name: b"assoc_expand_once\0" as *const u8 as *const libc::c_char
as *mut libc::c_char,
value: &assoc_expand_once as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"cdable_vars\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"cdable_vars\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &cdable_vars as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"cdspell\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"cdspell\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &cdspelling as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"checkhash\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"checkhash\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &check_hashed_filenames as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"checkjobs\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"checkjobs\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &check_jobs_at_exit as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"checkwinsize\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"checkwinsize\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &check_window_size as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"cmdhist\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
- value: &command_oriented_history as *const i32
- as *mut i32,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ name: b"cmdhist\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ value: &command_oriented_history as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"compat31\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat31\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT31 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat32\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat32\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT32 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat40\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat40\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT40 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat41\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat41\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT41 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat42\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat42\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT42 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat43\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat43\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT43 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"compat44\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"compat44\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_COMPAT44 as *const i32 as *mut libc::c_int,
set_func: Some(
- set_compatibility_level
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_compatibility_level as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
@@ -423,73 +370,60 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
name: b"complete_fullquote\0" as *const u8 as *const libc::c_char
as *mut libc::c_char,
value: &complete_fullquote as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"direxpand\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"direxpand\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &dircomplete_expand as *const i32 as *mut libc::c_int,
set_func: Some(
shopt_set_complete_direxpand
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"dirspell\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"dirspell\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &dircomplete_spelling as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"dotglob\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"dotglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &glob_dot_filenames as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"execfail\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"execfail\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &no_exit_on_failed_exec as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"expand_aliases\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"expand_aliases\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &expand_aliases as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -582,89 +516,72 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
},
{
let init = RShoptVars {
- name: b"gnu_errfmt\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"gnu_errfmt\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &gnu_error_format as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"histappend\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"histappend\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &force_append_history as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"histreedit\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"histreedit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &history_reediting as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"histverify\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"histverify\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &hist_verify as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"hostcomplete\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
- value: &perform_hostname_completion as *const i32
- as *mut i32,
+ name: b"hostcomplete\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ value: &perform_hostname_completion as *const i32 as *mut i32,
set_func: Some(
shopt_enable_hostname_completion
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"huponexit\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"huponexit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &hup_on_exit as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"inherit_errexit\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"inherit_errexit\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &inherit_errexit as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -675,35 +592,28 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
value: &interactive_comments as *const i32 as *mut libc::c_int,
set_func: Some(
set_shellopts_after_change
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"lastpipe\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"lastpipe\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &lastpipe_opt as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"lithist\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"lithist\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &literal_history as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -712,49 +622,39 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
name: b"localvar_inherit\0" as *const u8 as *const libc::c_char
as *mut libc::c_char,
value: &localvar_inherit as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"localvar_unset\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"localvar_unset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &localvar_unset as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"login_shell\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"login_shell\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &SHOPT_LOGIN_SHELL as *const i32 as *mut i32,
set_func: Some(
- r_set_login_shell
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ r_set_login_shell as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"mailwarn\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"mailwarn\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &mail_warning as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -762,86 +662,70 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
let init = RShoptVars {
name: b"no_empty_cmd_completion\0" as *const u8 as *const libc::c_char
as *mut libc::c_char,
- value: &no_empty_command_completion as *const i32
- as *mut i32,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ value: &no_empty_command_completion as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"nocaseglob\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"nocaseglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &glob_ignore_case as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"nocasematch\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"nocasematch\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &match_ignore_case as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"nullglob\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
- value: &allow_null_glob_expansion as *const i32
- as *mut i32,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ name: b"nullglob\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ value: &allow_null_glob_expansion as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"progcomp\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
- value: &prog_completion_enabled as *const i32
- as *mut i32,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ name: b"progcomp\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
+ value: &prog_completion_enabled as *const i32 as *mut i32,
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"progcomp_alias\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"progcomp_alias\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &progcomp_alias as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"promptvars\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"promptvars\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &promptvars as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -851,48 +735,38 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
as *mut libc::c_char,
value: &restricted_shell as *const i32 as *mut libc::c_int,
set_func: Some(
- set_restricted_shell
- as unsafe extern "C" fn(
- *mut libc::c_char,
- i32,
- ) -> i32,
+ set_restricted_shell as unsafe extern "C" fn(*mut libc::c_char, i32) -> i32,
),
};
init
},
{
let init = RShoptVars {
- name: b"shift_verbose\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"shift_verbose\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &print_shift_error as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"sourcepath\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"sourcepath\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &source_uses_path as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
{
let init = RShoptVars {
- name: b"xpg_echo\0" as *const u8 as *const libc::c_char
- as *mut libc::c_char,
+ name: b"xpg_echo\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
value: &xpg_echo as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -900,10 +774,9 @@ static mut SHOPT_VARS: [RShoptVars; 54] = unsafe {
let init = RShoptVars {
name: 0 as *const libc::c_char as *mut libc::c_char,
value: 0 as *const i32 as *mut libc::c_int,
- set_func: ::std::mem::transmute::<
- *mut libc::c_void,
- Option::,
- >(0 as *const libc::c_void as *mut libc::c_void),
+ set_func: ::std::mem::transmute::<*mut libc::c_void, Option>(
+ 0 as *const libc::c_void as *mut libc::c_void,
+ ),
};
init
},
@@ -1260,7 +1133,7 @@ unsafe extern "C" fn list_some_o_options(
unsafe extern "C" fn set_shopt_o_options(
mode: i32,
list: *mut WordList,
- quiet: i32,
+ _quiet: i32,
) -> i32 {
//let mut l: *mut WordList =0 as *mut WordList;
let mut l: *mut WordList;
@@ -1277,15 +1150,15 @@ unsafe extern "C" fn set_shopt_o_options(
return rval;
}
unsafe extern "C" fn set_shellopts_after_change(
- option_name: *mut libc::c_char,
- mode: i32,
+ _option_name: *mut libc::c_char,
+ _mode: i32,
) -> i32 {
r_set_shellopts();
return 0;
}
unsafe extern "C" fn shopt_set_debug_mode(
- option_name: *mut libc::c_char,
- mode: i32,
+ _option_name: *mut libc::c_char,
+ _mode: i32,
) -> i32 {
function_trace_mode = debugging_mode;
error_trace_mode = function_trace_mode;
@@ -1296,7 +1169,7 @@ unsafe extern "C" fn shopt_set_debug_mode(
return 0;
}
unsafe extern "C" fn shopt_enable_hostname_completion(
- option_name: *mut libc::c_char,
+ _option_name: *mut libc::c_char,
mode: i32,
) -> i32 {
return enable_hostname_completion(mode);
@@ -1379,15 +1252,15 @@ pub unsafe extern "C" fn r_set_compatibility_opts() {
};
}
unsafe extern "C" fn shopt_set_complete_direxpand(
- option_name: *mut libc::c_char,
- mode: i32,
+ _option_name: *mut libc::c_char,
+ _mode: i32,
) -> i32 {
set_directory_hook();
return 0;
}
unsafe extern "C" fn set_restricted_shell(
- option_name: *mut libc::c_char,
- mode: i32,
+ _option_name: *mut libc::c_char,
+ _mode: i32,
) -> i32 {
static mut SAVE_RESTRICTED:i32 = -1;
if SAVE_RESTRICTED == -1 {
@@ -1398,8 +1271,8 @@ unsafe extern "C" fn set_restricted_shell(
}
#[no_mangle]
pub unsafe extern "C" fn r_set_login_shell(
- option_name: *mut libc::c_char,
- mode: i32,
+ _option_name: *mut libc::c_char,
+ _mode: i32,
) -> i32 {
SHOPT_LOGIN_SHELL = if login_shell != 0 {1} else{0};
return 0;
@@ -1540,7 +1413,7 @@ pub unsafe extern "C" fn r_set_bashopts() {
libc::free(value as *mut libc::c_void);
}
#[no_mangle]
-pub unsafe extern "C" fn r_parse_bashopts( value: *mut libc::c_char) {
+pub unsafe extern "C" fn r_parse_bashopts(value: *mut libc::c_char) {
let mut vname: *mut libc::c_char = 0 as *mut libc::c_char;
let mut vptr: i32 = 0;
let mut ind: i32 = 0;
@@ -1558,31 +1431,27 @@ pub unsafe extern "C" fn r_parse_bashopts( value: *mut libc::c_char) {
((*SHOPT_VARS.as_mut_ptr().offset(ind as isize)).set_func)
.expect("non-null function pointer"),
))
- .expect(
- "non-null function pointer",
- )(SHOPT_VARS[ind as usize].name, 1 as i32);
+ .expect("non-null function pointer")(
+ SHOPT_VARS[ind as usize].name, 1 as i32
+ );
}
}
free(vname as *mut libc::c_void);
- };
+ }
}
#[no_mangle]
pub unsafe extern "C" fn r_initialize_bashopts(no_bashopts: i32) {
- let temp: *mut libc::c_char;
- let var: *mut ShellVar;
+ let temp: *mut libc::c_char;
+ let var: *mut ShellVar;
if no_bashopts == 0 {
var = find_variable(b"BASHOPTS\0" as *const u8 as *const libc::c_char);
if !var.is_null() && (*var).attributes & att_imported != 0 {
- temp = if (*var).attributes & att_array != 0
- || (*var).attributes & att_assoc != 0
- {
+ temp = if (*var).attributes & att_array != 0 || (*var).attributes & att_assoc != 0 {
std::ptr::null_mut()
} else {
strcpy(
- xmalloc(
- (1 as libc::c_ulong)
- .wrapping_add(strlen((*var).value)),
- ) as *mut libc::c_char,
+ xmalloc((1 as libc::c_ulong).wrapping_add(strlen((*var).value)))
+ as *mut libc::c_char,
(*var).value,
)
};
@@ -1594,4 +1463,3 @@ pub unsafe extern "C" fn r_initialize_bashopts(no_bashopts: i32) {
}
r_set_bashopts();
}
-
diff --git a/bash-5.1/builtins_rust/source/src/lib.rs b/bash-5.1/builtins_rust/source/src/lib.rs
index 4c726b650e3c4d8283520d00d872d7142cd0511c..a47c53c2d680b1168b2b05ef1912617c68b3e025 100644
--- a/bash-5.1/builtins_rust/source/src/lib.rs
+++ b/bash-5.1/builtins_rust/source/src/lib.rs
@@ -1,130 +1,155 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
-use libc::{c_char, c_long, c_void};
-use std::{ffi::CString};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage, r_savestring};
-use rhelp::r_builtin_help;
+use libc::{c_char, c_void};
+use rcommon::{r_savestring, WordDesc, WordList, EXECUTION_FAILURE, EX_USAGE};
+use std::ffi::CString;
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:libc::c_int,
- rflags:libc::c_int,
- flags:libc::c_int,
- instruction:r_instruction,
- redirectee:libc::c_int,
- here_doc_eof:*mut c_char
+ next: *mut REDIRECT,
+ redirector: libc::c_int,
+ rflags: libc::c_int,
+ flags: libc::c_int,
+ instruction: r_instruction,
+ redirectee: libc::c_int,
+ here_doc_eof: *mut c_char,
}
/* FOR command. */
#[repr(C)]
pub struct for_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:libc::c_int
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: libc::c_int,
}
#[repr(C)]
pub struct case_com {
- flags:libc::c_int,
- line:libc::c_int,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ flags: libc::c_int,
+ line: libc::c_int,
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct while_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
- flags:libc::c_int,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ flags: libc::c_int,
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore:libc::c_int,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector:libc::c_int
+ ignore: libc::c_int,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: libc::c_int,
}
#[repr(C)]
pub struct simple_com {
- flags:libc::c_int,
- line:libc::c_int,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: libc::c_int,
+ line: libc::c_int,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut c_char
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct group_com {
- ignore:libc::c_int,
- command:*mut COMMAND,
- source_file:*mut c_char
+ ignore: libc::c_int,
+ command: *mut COMMAND,
+ source_file: *mut c_char,
}
#[repr(C)]
pub struct select_com {
- flags:libc::c_int,
- line:libc::c_int,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct arith_com {
- flags:libc::c_int,
- line:libc::c_int,
- exp:*mut WordList
+ flags: libc::c_int,
+ line: libc::c_int,
+ exp: *mut WordList,
}
#[repr(C)]
@@ -137,12 +162,12 @@ pub struct cond_com {
#[repr(C)]
pub struct arith_for_com {
- flags:libc::c_int,
- line:libc::c_int,
- init:*mut WordList,
- test:*mut WordList,
- step:*mut WordList,
- action:*mut COMMAND
+ flags: libc::c_int,
+ line: libc::c_int,
+ init: *mut WordList,
+ test: *mut WordList,
+ step: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
@@ -285,7 +310,7 @@ unsafe fn DEBUG_TRAP()->i32
pub extern "C" fn r_source_builtin (list:* mut WordList)->i32
{
- let mut result:i32;
+ let result:i32;
let mut filename:*mut c_char;
let mut debug_trap:* mut c_char;
let x:* mut c_char;
@@ -294,7 +319,7 @@ pub extern "C" fn r_source_builtin (list:* mut WordList)->i32
return EX_USAGE;
}
- let mut llist:* mut WordList = loptend.clone();
+ let llist:* mut WordList = loptend.clone();
if list == std::ptr::null_mut() {
builtin_error (b"filename argument required\0" as *const u8 as *const libc::c_char as *mut libc::c_char );
@@ -369,11 +394,8 @@ pub extern "C" fn r_source_builtin (list:* mut WordList)->i32
restore_default_signal (DEBUG_TRAP());
}
- result = source_file (filename, (list !=std::ptr::null_mut() && (*list).next !=std::ptr::null_mut()) as i32);
-
- run_unwind_frame (b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char);
+ run_unwind_frame(b"source\0" as *const u8 as *const libc::c_char as *mut libc::c_char);
- return result;
- }
+ return result;
+ }
}
-
diff --git a/bash-5.1/builtins_rust/suspend/src/lib.rs b/bash-5.1/builtins_rust/suspend/src/lib.rs
index 272065d7ec04ce35ef82d711ab6659862f4d246a..0ce925d7b5a114a0a18b7d19140eb56998298550 100644
--- a/bash-5.1/builtins_rust/suspend/src/lib.rs
+++ b/bash-5.1/builtins_rust/suspend/src/lib.rs
@@ -1,8 +1,8 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char, c_long, PT_NULL};
-use rcommon::{r_no_args,WordList,r_builtin_usage};
+use libc::{c_char, c_int, c_long, PT_NULL};
+use rcommon::{r_builtin_usage, r_no_args, WordList};
use rhelp::r_builtin_help;
include!(concat!("intercdep.rs"));
@@ -10,50 +10,51 @@ pub static mut old_cont: *mut SigHandler = PT_NULL as *mut SigHandler;
#[no_mangle]
pub extern "C" fn r_suspend_builtin(mut list: *mut WordList) -> i32 {
-
let mut opt: c_int;
let mut force: c_int = 0;
-unsafe {
- reset_internal_getopt();
- let opt_str = "f\0".as_ptr() as *mut c_char;
- opt = internal_getopt (list, opt_str);
- while opt != -1 {
- let opt_char:char=char::from(opt as u8);
- match opt_char {
- 'f' => force += 1,
- _ => {
- if opt == -99 {
- r_builtin_help();
+ unsafe {
+ reset_internal_getopt();
+ let opt_str = "f\0".as_ptr() as *mut c_char;
+ opt = internal_getopt(list, opt_str);
+ while opt != -1 {
+ let opt_char: char = char::from(opt as u8);
+ match opt_char {
+ 'f' => force += 1,
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ r_builtin_usage();
return EX_USAGE;
}
- r_builtin_usage ();
- return EX_USAGE;
}
+
+ opt = internal_getopt(list, opt_str);
}
-
- opt = internal_getopt (list, opt_str);
- }
- list = loptend;
- if job_control == 0 {
- sh_nojobs("cannot suspend\0".as_ptr() as *mut c_char);
- return EXECUTION_FAILURE;
- }
- if force == 0 {
- r_no_args(list);
- if login_shell != 0 {
- builtin_error("cannot suspend a login shell\0".as_ptr() as *mut c_char);
+ list = loptend;
+ if job_control == 0 {
+ sh_nojobs("cannot suspend\0".as_ptr() as *mut c_char);
return EXECUTION_FAILURE;
}
- }
+ if force == 0 {
+ r_no_args(list);
+ if login_shell != 0 {
+ builtin_error("cannot suspend a login shell\0".as_ptr() as *mut c_char);
+ return EXECUTION_FAILURE;
+ }
+ }
- old_cont = set_signal_handler(libc::SIGCONT, std::mem::transmute(suspend_continue as usize));
- killpg(shell_pgrp, libc::SIGSTOP);
-}
+ old_cont = set_signal_handler(
+ libc::SIGCONT,
+ std::mem::transmute(suspend_continue as usize),
+ );
+ killpg(shell_pgrp, libc::SIGSTOP);
+ }
return EXECUTION_SUCCESS;
}
-unsafe fn suspend_continue(sig: c_int)
-{
+unsafe fn suspend_continue(sig: c_int) {
set_signal_handler(libc::SIGCONT, old_cont);
}
diff --git a/bash-5.1/builtins_rust/test/src/lib.rs b/bash-5.1/builtins_rust/test/src/lib.rs
index bc6d40ef4b6abf7527665915baf6999e0cb4e40c..a7daf5dd74b4aee1d141b5c4573e83b860662463 100644
--- a/bash-5.1/builtins_rust/test/src/lib.rs
+++ b/bash-5.1/builtins_rust/test/src/lib.rs
@@ -1,39 +1,38 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char, c_void};
-use std::ffi::{CStr, CString};
-use rcommon::{r_make_builtin_argv,WordList};
+use libc::{c_char, c_int, c_void};
+
+use rcommon::{r_make_builtin_argv, WordList};
include!(concat!("intercdep.rs"));
-use rhelp::r_builtin_help;
#[no_mangle]
pub extern "C" fn r_test_builtin(list: *mut WordList) -> i32 {
-
let result: c_int;
- let mut argc: c_int = 0;
-unsafe {
- if list.is_null() {
- if *this_command_name == b'[' as c_char &&
- *((this_command_name as usize + 1) as *mut c_char) == 0 {
- builtin_error("missing `]'\0".as_ptr() as *mut c_char);
- return EX_BADUSAGE;
+ let argc: c_int = 0;
+ unsafe {
+ if list.is_null() {
+ if *this_command_name == b'[' as c_char
+ && *((this_command_name as usize + 1) as *mut c_char) == 0
+ {
+ builtin_error("missing `]'\0".as_ptr() as *mut c_char);
+ return EX_BADUSAGE;
+ }
+ return EXECUTION_FAILURE;
}
- return EXECUTION_FAILURE;
- }
- let argv = r_make_builtin_argv(list, std::mem::transmute(&argc));
- /*
- let mut i = 0;
- let argv = r_make_builtin_argv(list, &argc as *const i32 as*mut i32);
- while i<(argc) {
- let tmp = CStr::from_ptr(argv as *mut c_char);
- //println!("test argv={}", tmp.to_str().unwrap());
- libc::printf(CString::new("test:i=%d, argv=%s=\n").unwrap().as_ptr(), i , *argv.offset(i as isize) as *mut c_char);
- i=i+1;
+ let argv = r_make_builtin_argv(list, std::mem::transmute(&argc));
+ /*
+ let mut i = 0;
+ let argv = r_make_builtin_argv(list, &argc as *const i32 as*mut i32);
+ while i<(argc) {
+ let tmp = CStr::from_ptr(argv as *mut c_char);
+ //println!("test argv={}", tmp.to_str().unwrap());
+ libc::printf(CString::new("test:i=%d, argv=%s=\n").unwrap().as_ptr(), i , *argv.offset(i as isize) as *mut c_char);
+ i=i+1;
+ }
+ */
+ result = test_command(argc, argv);
+ libc::free(argv as *mut c_void);
}
- */
- result = test_command(argc, argv);
- libc::free(argv as *mut c_void);
-}
return result;
}
diff --git a/bash-5.1/builtins_rust/times/src/lib.rs b/bash-5.1/builtins_rust/times/src/lib.rs
index 38eed28980943908729e3fe2554b3b78a461ebe9..b7c6e4144a455e267bc162a1a9393a839ac69013 100644
--- a/bash-5.1/builtins_rust/times/src/lib.rs
+++ b/bash-5.1/builtins_rust/times/src/lib.rs
@@ -1,36 +1,34 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use libc::{c_int, c_char};
-use rcommon::{r_sh_chkwrite};
+use libc::c_int;
+use rcommon::r_sh_chkwrite;
include!(concat!("intercdep.rs"));
#[no_mangle]
pub extern "C" fn r_times_builtin(list: *mut WordList) -> i32 {
+ unsafe {
+ if no_options(list) != 0 {
+ return EX_USAGE;
+ }
-unsafe {
+ let curr: libc::rusage = std::mem::zeroed();
+ let kids: libc::rusage = std::mem::zeroed();
+ libc::putchar(b'\n' as c_int);
- if no_options(list) != 0 {
- return EX_USAGE;
- }
-
- let mut curr: libc::rusage = std::mem::zeroed();
- let mut kids: libc::rusage = std::mem::zeroed();
- libc::putchar(b'\n' as c_int);
-
- libc::getrusage(libc::RUSAGE_SELF, std::mem::transmute(&curr));
- libc::getrusage(libc::RUSAGE_CHILDREN, std::mem::transmute(&kids));
+ libc::getrusage(libc::RUSAGE_SELF, std::mem::transmute(&curr));
+ libc::getrusage(libc::RUSAGE_CHILDREN, std::mem::transmute(&kids));
- print_timeval(stdout, std::mem::transmute(&curr.ru_utime));
- libc::putchar(b' ' as c_int);
- print_timeval(stdout, std::mem::transmute(&curr.ru_stime));
- libc::putchar(b'\n' as c_int);
+ print_timeval(stdout, std::mem::transmute(&curr.ru_utime));
+ libc::putchar(b' ' as c_int);
+ print_timeval(stdout, std::mem::transmute(&curr.ru_stime));
+ libc::putchar(b'\n' as c_int);
- print_timeval(stdout, std::mem::transmute(&kids.ru_utime));
- libc::putchar(b' ' as c_int);
- print_timeval(stdout, std::mem::transmute(&kids.ru_stime));
- libc::putchar(b'\n' as c_int);
+ print_timeval(stdout, std::mem::transmute(&kids.ru_utime));
+ libc::putchar(b' ' as c_int);
+ print_timeval(stdout, std::mem::transmute(&kids.ru_stime));
+ libc::putchar(b'\n' as c_int);
- return r_sh_chkwrite(EXECUTION_SUCCESS);
-}
+ return r_sh_chkwrite(EXECUTION_SUCCESS);
+ }
}
diff --git a/bash-5.1/builtins_rust/trap/src/lib.rs b/bash-5.1/builtins_rust/trap/src/lib.rs
index 4bb47528da36b9a98e89f9d19d00eb856143fe81..6c15d229124e8eb52cf5513373105c49c9dbfd07 100644
--- a/bash-5.1/builtins_rust/trap/src/lib.rs
+++ b/bash-5.1/builtins_rust/trap/src/lib.rs
@@ -1,127 +1,147 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-use std::{ffi::CString};
+use std::ffi::CString;
-use libc::{c_int, c_char, c_void, PT_NULL};
-use rcommon::{r_builtin_usage,r_display_signal_list,WordList,r_sh_invalidsig,r_sh_chkwrite};
+use libc::{c_char, c_int, c_void, PT_NULL};
+use rcommon::{r_builtin_usage, r_display_signal_list, r_sh_chkwrite, r_sh_invalidsig, WordList};
use rhelp::r_builtin_help;
include!(concat!("intercdep.rs"));
-
#[no_mangle]
pub extern "C" fn r_trap_builtin(mut list: *mut WordList) -> i32 {
-
let mut list_signal_names: c_int = 0;
let mut display: c_int = 0;
let mut result: c_int = EXECUTION_SUCCESS;
-unsafe {
- reset_internal_getopt();
- let opt_str = CString::new("lp").unwrap();
- let mut opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- while opt != -1 {
- let opt_char:char=char::from(opt as u8);
- match opt_char {
- 'l' => list_signal_names += 1,
- 'p' => display += 1,
- _ => {
- if opt == -99 {
- r_builtin_help();
+ unsafe {
+ reset_internal_getopt();
+ let opt_str = CString::new("lp").unwrap();
+ let mut opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
+ while opt != -1 {
+ let opt_char: char = char::from(opt as u8);
+ match opt_char {
+ 'l' => list_signal_names += 1,
+ 'p' => display += 1,
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ r_builtin_usage();
return EX_USAGE;
}
- r_builtin_usage ();
- return EX_USAGE;
}
+ opt = internal_getopt(list, opt_str.as_ptr() as *mut c_char);
}
- opt = internal_getopt (list, opt_str.as_ptr() as * mut c_char);
- }
- list = loptend;
-
- opt = DSIG_NOCASE | DSIG_SIGPREFIX;
-
- if list_signal_names != 0 {
- return r_sh_chkwrite(r_display_signal_list(PT_NULL as *mut WordList, 1));
- } else if display != 0 || list.is_null() {
- initialize_terminating_signals();
- get_all_original_signals();
- return r_sh_chkwrite(display_traps(list, (display != 0 && posixly_correct != 0) as c_int));
- } else {
- let mut operation = SET;
- let first_arg = (*(*list).word).word;
- let first_signal = !first_arg.is_null() && *first_arg != 0 &&
- all_digits(first_arg) != 0 && decode_signal (first_arg,opt) != NO_SIG;
- if first_signal {
- operation = REVERT;
- } else if posixly_correct == 0 && !first_arg.is_null() && *first_arg != 0 &&
- (*first_arg != b'-' as c_char || *((first_arg as usize + 1) as *mut c_char) != 0 ) &&
- decode_signal (first_arg,opt) != NO_SIG && (*list).next.is_null() {
- operation = REVERT;
+ list = loptend;
+
+ opt = DSIG_NOCASE | DSIG_SIGPREFIX;
+
+ if list_signal_names != 0 {
+ return r_sh_chkwrite(r_display_signal_list(PT_NULL as *mut WordList, 1));
+ } else if display != 0 || list.is_null() {
+ initialize_terminating_signals();
+ get_all_original_signals();
+ return r_sh_chkwrite(display_traps(
+ list,
+ (display != 0 && posixly_correct != 0) as c_int,
+ ));
} else {
- list = (*list).next;
- if list.is_null() {
- r_builtin_usage();
- return EX_USAGE;
- } else if *first_arg == b'\0' as c_char {
- operation = IGNORE;
- } else if *first_arg == b'-' as c_char && *((first_arg as usize + 1) as *mut c_char) == 0 {
+ let mut operation = SET;
+ let first_arg = (*(*list).word).word;
+ let first_signal = !first_arg.is_null()
+ && *first_arg != 0
+ && all_digits(first_arg) != 0
+ && decode_signal(first_arg, opt) != NO_SIG;
+ if first_signal {
operation = REVERT;
+ } else if posixly_correct == 0
+ && !first_arg.is_null()
+ && *first_arg != 0
+ && (*first_arg != b'-' as c_char || *((first_arg as usize + 1) as *mut c_char) != 0)
+ && decode_signal(first_arg, opt) != NO_SIG
+ && (*list).next.is_null()
+ {
+ operation = REVERT;
+ } else {
+ list = (*list).next;
+ if list.is_null() {
+ r_builtin_usage();
+ return EX_USAGE;
+ } else if *first_arg == b'\0' as c_char {
+ operation = IGNORE;
+ } else if *first_arg == b'-' as c_char
+ && *((first_arg as usize + 1) as *mut c_char) == 0
+ {
+ operation = REVERT;
+ }
}
- }
- if subshell_environment & SUBSHELL_RESETTRAP != 0 {
- free_trap_strings();
- subshell_environment &= !SUBSHELL_RESETTRAP;
- }
+ if subshell_environment & SUBSHELL_RESETTRAP != 0 {
+ free_trap_strings();
+ subshell_environment &= !SUBSHELL_RESETTRAP;
+ }
- let mut sig: c_int;
- while !list.is_null() {
- sig = decode_signal((*(*list).word).word, opt);
- if sig == NO_SIG {
- r_sh_invalidsig((*(*list).word).word);
- result = EXECUTION_FAILURE;
- } else {
- match operation {
- SET => set_signal(sig, first_arg),
- IGNORE => ignore_signal(sig),
- REVERT => {
- restore_default_signal(sig);
- match sig {
- libc::SIGINT => {
- if interactive != 0 {
- set_signal_handler(libc::SIGINT, sigint_sighandler as *mut SigHandler);
- } else if interactive_shell != 0 &&
- (sourcelevel != 0 || running_trap != 0 || parse_and_execute_level != 0) {
- set_signal_handler(libc::SIGINT, sigint_sighandler as *mut SigHandler);
- } else {
- set_signal_handler(libc::SIGINT, termsig_sighandler as *mut SigHandler);
+ let mut sig: c_int;
+ while !list.is_null() {
+ sig = decode_signal((*(*list).word).word, opt);
+ if sig == NO_SIG {
+ r_sh_invalidsig((*(*list).word).word);
+ result = EXECUTION_FAILURE;
+ } else {
+ match operation {
+ SET => set_signal(sig, first_arg),
+ IGNORE => ignore_signal(sig),
+ REVERT => {
+ restore_default_signal(sig);
+ match sig {
+ libc::SIGINT => {
+ if interactive != 0 {
+ set_signal_handler(
+ libc::SIGINT,
+ sigint_sighandler as *mut SigHandler,
+ );
+ } else if interactive_shell != 0
+ && (sourcelevel != 0
+ || running_trap != 0
+ || parse_and_execute_level != 0)
+ {
+ set_signal_handler(
+ libc::SIGINT,
+ sigint_sighandler as *mut SigHandler,
+ );
+ } else {
+ set_signal_handler(
+ libc::SIGINT,
+ termsig_sighandler as *mut SigHandler,
+ );
+ }
}
- }
- libc::SIGQUIT => {
- set_signal_handler(libc::SIGQUIT, std::mem::transmute(1_usize));
- }
- libc::SIGTERM | libc::SIGTTIN | libc::SIGTTOU | libc::SIGTSTP => {
- if interactive != 0 {
- set_signal_handler(sig, std::mem::transmute(1_usize));
+ libc::SIGQUIT => {
+ set_signal_handler(libc::SIGQUIT, std::mem::transmute(1_usize));
+ }
+ libc::SIGTERM | libc::SIGTTIN | libc::SIGTTOU | libc::SIGTSTP => {
+ if interactive != 0 {
+ set_signal_handler(sig, std::mem::transmute(1_usize));
+ }
}
+ _ => (),
}
- _ => (),
+ break;
}
- break;
+ _ => (),
}
- _ => (),
}
- }
- list = (*list).next;
+ list = (*list).next;
+ }
}
}
-}
return result;
}
-unsafe fn showtrap(i: c_int, show_default: c_int)
-{
+unsafe fn showtrap(i: c_int, show_default: c_int) {
let t: *mut c_char;
let p = trap_list[i as usize];
@@ -134,21 +154,58 @@ unsafe fn showtrap(i: c_int, show_default: c_int)
} else if signal_is_hard_ignored(i) != 0 {
t = PT_NULL as *mut c_char;
} else {
- t = if p == libc::SIG_IGN as *mut c_char {PT_NULL as *mut c_char} else {sh_single_quote(p)}
+ t = if p == libc::SIG_IGN as *mut c_char {
+ PT_NULL as *mut c_char
+ } else {
+ sh_single_quote(p)
+ }
}
let sn = signal_name(i);
- if libc::strncmp(sn, "SIGJUNK\0".as_ptr() as *const c_char, 7) == 0 ||
- libc::strncmp(sn, "unknown\0".as_ptr() as *const c_char, 7) == 0 {
- libc::printf("trap -- %s %d\n\0".as_ptr() as *const c_char, if t.is_null() {"''\0".as_ptr() as *mut c_char} else {t}, i);
+ if libc::strncmp(sn, "SIGJUNK\0".as_ptr() as *const c_char, 7) == 0
+ || libc::strncmp(sn, "unknown\0".as_ptr() as *const c_char, 7) == 0
+ {
+ libc::printf(
+ "trap -- %s %d\n\0".as_ptr() as *const c_char,
+ if t.is_null() {
+ "''\0".as_ptr() as *mut c_char
+ } else {
+ t
+ },
+ i,
+ );
} else if posixly_correct != 0 {
if libc::strncmp(sn, "SIG\0".as_ptr() as *const c_char, 3) == 0 {
- libc::printf("trap -- %s %s\n\0".as_ptr() as *const c_char, if t.is_null() {"''\0".as_ptr() as *mut c_char} else {t}, (sn as usize + 3) as *mut c_char);
+ libc::printf(
+ "trap -- %s %s\n\0".as_ptr() as *const c_char,
+ if t.is_null() {
+ "''\0".as_ptr() as *mut c_char
+ } else {
+ t
+ },
+ (sn as usize + 3) as *mut c_char,
+ );
} else {
- libc::printf("trap -- %s %s\n\0".as_ptr() as *const c_char, if t.is_null() {"''\0".as_ptr() as *mut c_char} else {t}, sn);
+ libc::printf(
+ "trap -- %s %s\n\0".as_ptr() as *const c_char,
+ if t.is_null() {
+ "''\0".as_ptr() as *mut c_char
+ } else {
+ t
+ },
+ sn,
+ );
}
} else {
- libc::printf("trap -- %s %s\n\0".as_ptr() as *const c_char, if t.is_null() {"''\0".as_ptr() as *mut c_char} else {t}, sn);
+ libc::printf(
+ "trap -- %s %s\n\0".as_ptr() as *const c_char,
+ if t.is_null() {
+ "''\0".as_ptr() as *mut c_char
+ } else {
+ t
+ },
+ sn,
+ );
}
if show_default == 0 {
@@ -158,8 +215,7 @@ unsafe fn showtrap(i: c_int, show_default: c_int)
}
}
-unsafe fn display_traps(mut list: *mut WordList, show_all: c_int) -> c_int
-{
+unsafe fn display_traps(mut list: *mut WordList, show_all: c_int) -> c_int {
if list.is_null() {
for i in 0..BASH_NSIG {
showtrap(i, show_all);
diff --git a/bash-5.1/builtins_rust/type/src/lib.rs b/bash-5.1/builtins_rust/type/src/lib.rs
index be74225bd818649b9c855c150c4733680c0f6c90..70a4b2c8b55147d55f5512726442198bbd09ddb9 100644
--- a/bash-5.1/builtins_rust/type/src/lib.rs
+++ b/bash-5.1/builtins_rust/type/src/lib.rs
@@ -1,351 +1,409 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
use libc::c_void;
use std::ffi::CStr;
use std::ffi::CString;
-use std::ptr;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage,get_local_str};
+
+use rcommon::{get_local_str, WordDesc, WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
-use fluent_bundle::{FluentBundle, FluentResource, FluentValue, FluentArgs};
+use fluent_bundle::FluentArgs;
use fluent_resmgr::resource_manager::ResourceManager;
#[macro_export]
-macro_rules! CDESC_ALL{
+macro_rules! CDESC_ALL {
//print all descriptions of a command
- () => {0x001}
+ () => {
+ 0x001
+ };
}
#[macro_export]
macro_rules! CDESC_SHORTDESC {
//print the description for type and command -V
- () => {0x002}
+ () => {
+ 0x002
+ };
}
#[macro_export]
-macro_rules! CDESC_REUSABLE{
+macro_rules! CDESC_REUSABLE {
//print in a format that may be reused as input
- () => {0x004}
+ () => {
+ 0x004
+ };
}
#[macro_export]
macro_rules! CDESC_TYPE {
//print the type for type -t
- () => {0x008}
+ () => {
+ 0x008
+ };
}
#[macro_export]
macro_rules! CDESC_PATH_ONLY {
//print the path for type -p
- () => {0x010}
+ () => {
+ 0x010
+ };
}
#[macro_export]
macro_rules! CDESC_FORCE_PATH {
//force a path search for type -P
- () => {0x020}
+ () => {
+ 0x020
+ };
}
#[macro_export]
macro_rules! CDESC_NOFUNCS {
//skip function lookup for type -f
- () => {0x040}
+ () => {
+ 0x040
+ };
}
#[macro_export]
-macro_rules! CDESC_ABSPATH{
+macro_rules! CDESC_ABSPATH {
//CDESC_ABSPATH
- () => {0x080}
+ () => {
+ 0x080
+ };
}
#[macro_export]
-macro_rules! CDESC_STDPATH{
- () => {0x100}
+macro_rules! CDESC_STDPATH {
+ () => {
+ 0x100
+ };
}
#[macro_export]
macro_rules! CHECK_HELPOPT {
- ($l:expr) => {
- if $l !=std::ptr::null_mut() && (*$l).word !=std::ptr::null_mut() && ISHELP!((*(*$l).word).word) == 0 {
- r_builtin_help ();
- return EX_USAGE;
- }
- }
+ ($l:expr) => {
+ if $l != std::ptr::null_mut()
+ && (*$l).word != std::ptr::null_mut()
+ && ISHELP!((*(*$l).word).word) == 0
+ {
+ r_builtin_help();
+ return EX_USAGE;
+ }
+ };
}
-
-
#[macro_export]
-macro_rules! FS_EXECABLE{
- () => {0x2}
+macro_rules! FS_EXECABLE {
+ () => {
+ 0x2
+ };
}
#[macro_export]
-macro_rules! FS_EXEC_PREFERRED{
- () => {0x4}
+macro_rules! FS_EXEC_PREFERRED {
+ () => {
+ 0x4
+ };
}
#[macro_export]
-macro_rules! FS_NODIRS{
- () => {0x20}
+macro_rules! FS_NODIRS {
+ () => {
+ 0x20
+ };
}
#[macro_export]
-macro_rules! MP_DOCWD{
- () => {0}
+macro_rules! MP_DOCWD {
+ () => {
+ 0
+ };
}
#[macro_export]
-macro_rules! MP_RMDOT{
- () => {1}
+macro_rules! MP_RMDOT {
+ () => {
+ 1
+ };
}
#[deny(missing_fragment_specifier)]
#[macro_export]
-macro_rules! STREQ{
- ($a:expr,$b:expr) =>{
- *$a as libc::c_char == *$b as libc::c_char && libc::strcmp($a,$b)==0
- }
+macro_rules! STREQ {
+ ($a:expr,$b:expr) => {
+ *$a as libc::c_char == *$b as libc::c_char && libc::strcmp($a, $b) == 0
+ };
}
#[macro_export]
-macro_rules! SIZEOFWORD{
+macro_rules! SIZEOFWORD {
() => {
- std::mem::size_of::()
- }
+ std::mem::size_of::()
+ };
}
-
#[repr(C)]
pub struct SHELL_VAR {
- name:*mut libc::c_char,
- value:*mut libc::c_char,
- exportstr:*mut libc::c_char,
- dynamic_value:*mut fn(v:* mut SHELL_VAR)->*mut SHELL_VAR,
- assign_func:* mut fn(v:* mut SHELL_VAR,str1:* mut libc::c_char,t:i64,str2:* mut libc::c_char)->*mut SHELL_VAR,
- attributes:i32,
- context:i32
+ name: *mut libc::c_char,
+ value: *mut libc::c_char,
+ exportstr: *mut libc::c_char,
+ dynamic_value: *mut fn(v: *mut SHELL_VAR) -> *mut SHELL_VAR,
+ assign_func: *mut fn(
+ v: *mut SHELL_VAR,
+ str1: *mut libc::c_char,
+ t: i64,
+ str2: *mut libc::c_char,
+ ) -> *mut SHELL_VAR,
+ attributes: i32,
+ context: i32,
}
-#[repr (C)]
-#[derive(Copy,Clone)]
+#[repr(C)]
+#[derive(Copy, Clone)]
pub struct alias {
- name :*mut libc::c_char,
- value :*mut libc::c_char ,
- flags:libc::c_char
+ name: *mut libc::c_char,
+ value: *mut libc::c_char,
+ flags: libc::c_char,
}
type sh_builtin_func_t = fn(WordList) -> i32;
type alias_t = alias;
-pub fn math(op: fn(i32, i32) -> i32, a: i32, b: i32) -> i32{
+pub fn math(op: fn(i32, i32) -> i32, a: i32, b: i32) -> i32 {
/// 通过函数指针调用函数
op(a, b)
}
-
#[repr(C)]
pub struct COMMAND {
- type_c:command_type,
- flags:i32,
- line:i32,
- redirects:*mut REDIRECT,
- value:VALUE_COMMAND
+ type_c: command_type,
+ flags: i32,
+ line: i32,
+ redirects: *mut REDIRECT,
+ value: VALUE_COMMAND,
}
#[repr(u8)]
-enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
- cm_connection, cm_function_def, cm_until, cm_group,
- cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc
+enum command_type {
+ cm_for,
+ cm_case,
+ cm_while,
+ cm_if,
+ cm_simple,
+ cm_select,
+ cm_connection,
+ cm_function_def,
+ cm_until,
+ cm_group,
+ cm_arith,
+ cm_cond,
+ cm_arith_for,
+ cm_subshell,
+ cm_coproc,
}
#[repr(C)]
pub union VALUE_COMMAND {
- For:*mut for_com,
- Case:*mut case_com,
- While:*mut while_com,
- If:*mut if_com,
- Connection:*mut connection,
- Simple:*mut simple_com,
- Function_def:*mut function_def,
- Group:*mut group_com,
- Select:*mut select_com,
- Arith:*mut arith_com,
- Cond:*mut cond_com,
- ArithFor:*mut arith_for_com,
- Subshell:*mut subshell_com,
- Coproc:*mut coproc_com
+ For: *mut for_com,
+ Case: *mut case_com,
+ While: *mut while_com,
+ If: *mut if_com,
+ Connection: *mut connection,
+ Simple: *mut simple_com,
+ Function_def: *mut function_def,
+ Group: *mut group_com,
+ Select: *mut select_com,
+ Arith: *mut arith_com,
+ Cond: *mut cond_com,
+ ArithFor: *mut arith_for_com,
+ Subshell: *mut subshell_com,
+ Coproc: *mut coproc_com,
}
#[repr(u8)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
enum r_instruction {
- r_output_direction, r_input_direction, r_inputa_direction,
- r_appending_to, r_reading_until, r_reading_string,
- r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
- r_close_this, r_err_and_out, r_input_output, r_output_force,
- r_duplicating_input_word, r_duplicating_output_word,
- r_move_input, r_move_output, r_move_input_word, r_move_output_word,
- r_append_err_and_out
+ r_output_direction,
+ r_input_direction,
+ r_inputa_direction,
+ r_appending_to,
+ r_reading_until,
+ r_reading_string,
+ r_duplicating_input,
+ r_duplicating_output,
+ r_deblank_reading_until,
+ r_close_this,
+ r_err_and_out,
+ r_input_output,
+ r_output_force,
+ r_duplicating_input_word,
+ r_duplicating_output_word,
+ r_move_input,
+ r_move_output,
+ r_move_input_word,
+ r_move_output_word,
+ r_append_err_and_out,
}
#[repr(C)]
pub union REDIRECT {
- next:*mut REDIRECT,
- redirector:REDIRECTEE,
- rflags: i32 ,
- flags: i32 ,
- instruction:r_instruction,
- redirectee:REDIRECTEE,
- here_doc_eof:*mut libc::c_char
+ next: *mut REDIRECT,
+ redirector: REDIRECTEE,
+ rflags: i32,
+ flags: i32,
+ instruction: r_instruction,
+ redirectee: REDIRECTEE,
+ here_doc_eof: *mut libc::c_char,
}
#[repr(C)]
pub struct for_com {
- flags: i32 ,
- line: i32 ,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: i32,
+ line: i32,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
-#[derive(Copy,Clone)]
+#[derive(Copy, Clone)]
pub union REDIRECTEE {
- dest: i32 ,
- filename:* mut WordDesc
+ dest: i32,
+ filename: *mut WordDesc,
}
#[repr(C)]
pub struct case_com {
flags: i32,
line: i32,
- word:*mut WordDesc,
- clauses:*mut PATTERN_LIST
+ word: *mut WordDesc,
+ clauses: *mut PATTERN_LIST,
}
#[repr(C)]
pub struct PATTERN_LIST {
- next:* mut PATTERN_LIST,
- patterns:* mut WordList,
- action:*mut COMMAND,
- flags:i32
+ next: *mut PATTERN_LIST,
+ patterns: *mut WordList,
+ action: *mut COMMAND,
+ flags: i32,
}
#[repr(C)]
pub struct while_com {
- flags: i32 ,
- test:*mut COMMAND,
- action:*mut COMMAND
+ flags: i32,
+ test: *mut COMMAND,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct if_com {
flags: i32,
- test:*mut COMMAND,
- true_case:*mut COMMAND,
- false_case:*mut COMMAND
+ test: *mut COMMAND,
+ true_case: *mut COMMAND,
+ false_case: *mut COMMAND,
}
#[repr(C)]
pub struct connection {
- ignore: i32 ,
- first:*mut COMMAND,
- second:*mut COMMAND,
- connector: i32
+ ignore: i32,
+ first: *mut COMMAND,
+ second: *mut COMMAND,
+ connector: i32,
}
#[repr(C)]
pub struct simple_com {
- flags: i32 ,
- line: i32 ,
- words:*mut WordList,
- redirects:*mut REDIRECT
+ flags: i32,
+ line: i32,
+ words: *mut WordList,
+ redirects: *mut REDIRECT,
}
#[repr(C)]
pub struct function_def {
- flags: i32 ,
- line: i32 ,
- name:*mut WordDesc,
- command:*mut COMMAND,
- source_file:*mut libc::c_char
+ flags: i32,
+ line: i32,
+ name: *mut WordDesc,
+ command: *mut COMMAND,
+ source_file: *mut libc::c_char,
}
#[repr(C)]
pub struct group_com {
- ignore: i32 ,
- command:*mut COMMAND,
- source_file:*mut libc::c_char
+ ignore: i32,
+ command: *mut COMMAND,
+ source_file: *mut libc::c_char,
}
#[repr(C)]
pub struct select_com {
- flags: i32 ,
- line: i32 ,
- name:*mut WordDesc,
- map_list:*mut WordList,
- action:*mut COMMAND
+ flags: i32,
+ line: i32,
+ name: *mut WordDesc,
+ map_list: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct arith_com {
- flags: i32 ,
- line: i32 ,
- exp:*mut WordList
+ flags: i32,
+ line: i32,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct cond_com {
- flags: i32 ,
- line: i32 ,
- type_c: i32 ,
- exp:*mut WordList
+ flags: i32,
+ line: i32,
+ type_c: i32,
+ exp: *mut WordList,
}
#[repr(C)]
pub struct arith_for_com {
- flags: i32 ,
- line: i32 ,
- init:*mut WordList,
- test:*mut WordList,
- step:*mut WordList,
- action:*mut COMMAND
+ flags: i32,
+ line: i32,
+ init: *mut WordList,
+ test: *mut WordList,
+ step: *mut WordList,
+ action: *mut COMMAND,
}
#[repr(C)]
pub struct subshell_com {
- flags:i32,
- line:i32,
- command:*mut COMMAND
+ flags: i32,
+ line: i32,
+ command: *mut COMMAND,
}
#[repr(C)]
pub struct coproc_com {
- flags:i32,
- name:*mut libc::c_char,
- command:*mut COMMAND
+ flags: i32,
+ name: *mut libc::c_char,
+ command: *mut COMMAND,
}
#[macro_export]
macro_rules! FUNC_MULTILINE {
- () => {
- 0x01
- }
+ () => {
+ 0x01
+ };
}
#[macro_export]
macro_rules! FUNC_EXTERNAL {
- () => {
- 0x02
- }
+ () => {
+ 0x02
+ };
}
#[macro_export]
macro_rules! FS_EXEC_ONLY {
() => {
- 0x8
- }
+ 0x8
+ };
}
#[macro_export]
@@ -353,7 +411,7 @@ macro_rules! ABSPATH {
($s :expr) => {
unsafe {
char::from(*($s as *mut libc::c_char) as u8) }== '/';
-
+
// $x == '/';
}
}
@@ -361,471 +419,476 @@ macro_rules! ABSPATH {
extern "C" {
fn reset_internal_getopt();
- fn internal_getopt (list:*mut WordList , opts:*mut libc::c_char)->i32;
+ fn internal_getopt(list: *mut WordList, opts: *mut libc::c_char) -> i32;
fn builtin_usage();
- fn sh_notfound (name:* mut libc::c_char);
- fn sh_chkwrite (ret:i32)->i32;
- fn find_alias(alia :*mut libc::c_char) ->alias_t;
+ fn sh_notfound(name: *mut libc::c_char);
+ fn sh_chkwrite(ret: i32) -> i32;
+ fn find_alias(alia: *mut libc::c_char) -> alias_t;
fn sh_single_quote(quote: *const libc::c_char) -> *mut libc::c_char;
- fn find_reserved_word(word: *mut libc::c_char)->i32;
- fn find_function (name:* const libc::c_char)-> *mut SHELL_VAR;
- fn named_function_string (name: *mut libc::c_char, cmd:* mut COMMAND, i:i32)->* mut libc::c_char;
+ fn find_reserved_word(word: *mut libc::c_char) -> i32;
+ fn find_function(name: *const libc::c_char) -> *mut SHELL_VAR;
+ fn named_function_string(
+ name: *mut libc::c_char,
+ cmd: *mut COMMAND,
+ i: i32,
+ ) -> *mut libc::c_char;
fn find_shell_builtin(builtin: *mut libc::c_char) -> *mut libc::c_char;
fn find_special_builtin(builtins: *mut libc::c_char) -> *mut sh_builtin_func_t;
- fn absolute_program(program:*const libc::c_char) -> i32;
- fn file_status(status :*const libc::c_char) -> i32 ;
- fn phash_search(search:*const libc::c_char) -> *mut libc::c_char;
+ fn absolute_program(program: *const libc::c_char) -> i32;
+ fn file_status(status: *const libc::c_char) -> i32;
+ fn phash_search(search: *const libc::c_char) -> *mut libc::c_char;
fn conf_standard_path() -> *mut libc::c_char;
- fn find_in_path(path1:*const libc::c_char, path2:*mut libc::c_char, num: i32) -> *mut libc::c_char;
- fn find_user_command(cmd:*mut libc::c_char) -> *mut libc::c_char;
- fn user_command_matches(cmd:*const libc::c_char, num1:i32, num2:i32) -> *mut libc::c_char;
- fn sh_makepath(path:*const libc::c_char, path1:*const libc::c_char, i: i32) -> *mut libc::c_char;
+ fn find_in_path(
+ path1: *const libc::c_char,
+ path2: *mut libc::c_char,
+ num: i32,
+ ) -> *mut libc::c_char;
+ fn find_user_command(cmd: *mut libc::c_char) -> *mut libc::c_char;
+ fn user_command_matches(cmd: *const libc::c_char, num1: i32, num2: i32) -> *mut libc::c_char;
+ fn sh_makepath(
+ path: *const libc::c_char,
+ path1: *const libc::c_char,
+ i: i32,
+ ) -> *mut libc::c_char;
//fn find_alias(alia : *mut libc::c_char) -> *mut alias_t;
- static expand_aliases : i32;
- static mut loptend:*mut WordList;
- static posixly_correct:i32;
+ static expand_aliases: i32;
+ static mut loptend: *mut WordList;
+ static posixly_correct: i32;
}
-unsafe fn function_cell(var:*mut SHELL_VAR) ->* mut COMMAND {
- return (*var).value as * mut COMMAND;
+unsafe fn function_cell(var: *mut SHELL_VAR) -> *mut COMMAND {
+ return (*var).value as *mut COMMAND;
}
#[no_mangle]
-pub unsafe extern "C" fn r_type_builtin (mut list :*mut WordList) -> i32 {
+pub unsafe extern "C" fn r_type_builtin(mut list: *mut WordList) -> i32 {
//println!("rtype is run");
- let mut dflags : i32;
- let mut any_failed: i32 = 0 ;
- let mut opt : i32 = 0;
- let mut this : *mut WordList;
-
- dflags = CDESC_SHORTDESC!(); /* default */
- unsafe{
- this = list;
- while this != std::ptr::null_mut() && char::from((*(*(*this).word).word) as u8) == '-' {
- let mut flag = (((*(*this).word).word) as usize + 1) as *mut libc::c_char;
- let mut c_str_type = CString::new("type").unwrap();
- let c_str_type1 = CString::new("-type").unwrap();
- let c_str_path = CString::new("path").unwrap();
- let c_str_path1 = CString::new("-path").unwrap();
- let c_str_all = CString::new("all").unwrap();
- let c_str_all1 = CString::new("-all").unwrap();
- if STREQ!(flag, c_str_type.as_ptr() as *mut libc::c_char ) || STREQ!(flag, c_str_type1.as_ptr() as *mut libc::c_char) {
- unsafe {
- *((*(*this).word).word).offset(1) = 't' as libc::c_char ;
- *((*(*this).word).word).offset(2) = '\0' as libc::c_char ;
- }
- }
- else if STREQ!(flag, c_str_path.as_ptr() as *mut libc::c_char) || STREQ!(flag, c_str_path1.as_ptr() as *mut libc::c_char){
- *((*(*this).word).word).offset(1) = 'p' as libc::c_char ;
- *((*(*this).word).word).offset(2) = '\0' as libc::c_char ;
- }
-
- else if STREQ!(flag, c_str_all.as_ptr() as *mut libc::c_char) || STREQ!(flag, c_str_all1.as_ptr() as *mut libc::c_char) {
- *((*(*this).word).word).offset(1) = 'a' as libc::c_char ;
- *((*(*this).word).word).offset(2) = '\0' as libc::c_char ;
- }
+ let mut dflags: i32;
+ let mut any_failed: i32 = 0;
+ let _opt: i32 = 0;
+ let mut this: *mut WordList;
- if (*this).next != std::ptr::null_mut(){
- this = (*this).next;
- }
- else {
- break;
- }
- }
-}
+ dflags = CDESC_SHORTDESC!(); /* default */
+ unsafe {
+ this = list;
+ while this != std::ptr::null_mut() && char::from((*(*(*this).word).word) as u8) == '-' {
+ let flag = (((*(*this).word).word) as usize + 1) as *mut libc::c_char;
+ let c_str_type = CString::new("type").unwrap();
+ let c_str_type1 = CString::new("-type").unwrap();
+ let c_str_path = CString::new("path").unwrap();
+ let c_str_path1 = CString::new("-path").unwrap();
+ let c_str_all = CString::new("all").unwrap();
+ let c_str_all1 = CString::new("-all").unwrap();
+ if STREQ!(flag, c_str_type.as_ptr() as *mut libc::c_char)
+ || STREQ!(flag, c_str_type1.as_ptr() as *mut libc::c_char)
+ {
+ unsafe {
+ *((*(*this).word).word).offset(1) = 't' as libc::c_char;
+ *((*(*this).word).word).offset(2) = '\0' as libc::c_char;
+ }
+ } else if STREQ!(flag, c_str_path.as_ptr() as *mut libc::c_char)
+ || STREQ!(flag, c_str_path1.as_ptr() as *mut libc::c_char)
+ {
+ *((*(*this).word).word).offset(1) = 'p' as libc::c_char;
+ *((*(*this).word).word).offset(2) = '\0' as libc::c_char;
+ } else if STREQ!(flag, c_str_all.as_ptr() as *mut libc::c_char)
+ || STREQ!(flag, c_str_all1.as_ptr() as *mut libc::c_char)
+ {
+ *((*(*this).word).word).offset(1) = 'a' as libc::c_char;
+ *((*(*this).word).word).offset(2) = '\0' as libc::c_char;
+ }
+
+ if (*this).next != std::ptr::null_mut() {
+ this = (*this).next;
+ } else {
+ break;
+ }
+ }
+ }
reset_internal_getopt();
- let c_str_afptP = CString::new("afptP").unwrap();
- let mut opt = unsafe {internal_getopt(list,c_str_afptP.as_ptr() as *mut libc::c_char) } ;
- while opt != -1{
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
- match optChar{
- 'a'=> {dflags = dflags |CDESC_ALL!();}
- 'f'=> {dflags = dflags | CDESC_NOFUNCS!(); }
- 'p'=> {dflags = dflags | CDESC_PATH_ONLY!();
- dflags = dflags& !(CDESC_TYPE!()|CDESC_SHORTDESC!()); }
- 't'=> {dflags = dflags | CDESC_TYPE!();
- dflags = dflags& !(CDESC_PATH_ONLY!()|CDESC_SHORTDESC!());}
- 'P'=> {dflags = dflags | CDESC_PATH_ONLY!()| CDESC_FORCE_PATH!();
- dflags = dflags& !(CDESC_TYPE!()|CDESC_SHORTDESC!());
+ let c_str_afptP = CString::new("afptP").unwrap();
+ let mut opt = unsafe { internal_getopt(list, c_str_afptP.as_ptr() as *mut libc::c_char) };
+ while opt != -1 {
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
+ match optChar {
+ 'a' => {
+ dflags = dflags | CDESC_ALL!();
+ }
+ 'f' => {
+ dflags = dflags | CDESC_NOFUNCS!();
+ }
+ 'p' => {
+ dflags = dflags | CDESC_PATH_ONLY!();
+ dflags = dflags & !(CDESC_TYPE!() | CDESC_SHORTDESC!());
+ }
+ 't' => {
+ dflags = dflags | CDESC_TYPE!();
+ dflags = dflags & !(CDESC_PATH_ONLY!() | CDESC_SHORTDESC!());
+ }
+ 'P' => {
+ dflags = dflags | CDESC_PATH_ONLY!() | CDESC_FORCE_PATH!();
+ dflags = dflags & !(CDESC_TYPE!() | CDESC_SHORTDESC!());
+ }
+ _ => {
+ if opt == -99 {
+ r_builtin_help();
+ return EX_USAGE;
}
- _ =>{
- if opt == -99 {
- r_builtin_help();
- return EX_USAGE;
- }
unsafe {
- builtin_usage ();
- return EX_USAGE;
+ builtin_usage();
+ return EX_USAGE;
}
}
- }
- opt = internal_getopt (list, c_str_afptP.as_ptr() as * mut libc::c_char);
- }
- list = loptend;
- while list != std::ptr::null_mut() {
- let found : i32;
+ }
+ opt = internal_getopt(list, c_str_afptP.as_ptr() as *mut libc::c_char);
+ }
+ list = loptend;
+ while list != std::ptr::null_mut() {
+ let found: i32;
unsafe {
- found = describe_command ((*(*list).word).word, dflags);
+ found = describe_command((*(*list).word).word, dflags);
}
- if found ==0 && (dflags & (CDESC_PATH_ONLY!()|CDESC_TYPE!()))==0 {
+ if found == 0 && (dflags & (CDESC_PATH_ONLY!() | CDESC_TYPE!())) == 0 {
unsafe {
sh_notfound((*(*list).word).word);
- }
+ }
}
any_failed = found + any_failed;
- any_failed == 0;
- // (any_failed += found) == 0;
- unsafe {
- list = (*list).next;
- }
-
+ let _ = any_failed == 0;
+ // (any_failed += found) == 0;
+ unsafe {
+ list = (*list).next;
+ }
}
- if any_failed == 0{
+ if any_failed == 0 {
EXECUTION_SUCCESS!();
- }
- else {
+ } else {
EXECUTION_FAILURE!();
}
- return unsafe{sh_chkwrite(opt)};
-}
-
-
-fn describe_command (command : *mut libc::c_char, dflags : i32) -> i32 {
- let mut found : i32 = 0;
- let mut i : i32;
- let mut found_file : i32 = 0;
- let mut f : i32;
- let mut all : i32;
- let mut full_path : *mut libc::c_char;
- let mut x : *mut libc::c_char;
- let mut pathlist : *mut libc::c_char;
- let mut func : *mut SHELL_VAR = 0 as *mut SHELL_VAR;
- // let mut alias : *mut alias_t;
-
- if (dflags & CDESC_ALL!()) != 0{
- all =1 ;
- }
- else {
+ return unsafe { sh_chkwrite(opt) };
+}
+
+fn describe_command(command: *mut libc::c_char, dflags: i32) -> i32 {
+ let mut found: i32 = 0;
+ let mut _i: i32;
+ let mut found_file: i32 = 0;
+ let mut f: i32;
+ let all: i32;
+ let mut full_path: *mut libc::c_char;
+ let mut x: *mut libc::c_char;
+ let mut pathlist: *mut libc::c_char;
+ let _func: *mut SHELL_VAR = 0 as *mut SHELL_VAR;
+ // let mut alias : *mut alias_t;
+
+ if (dflags & CDESC_ALL!()) != 0 {
+ all = 1;
+ } else {
all = 0;
}
unsafe {
- full_path = std::ptr::null_mut() ;
+ full_path = std::ptr::null_mut();
}
-/*
- // #if defined (ALIAS)
- alias = find_alias(command);
- if (((dflags & CDESC_FORCE_PATH!()) == 0) && expand_aliases!=0 && alias != std::ptr::null_mut())
- {
- if (dflags & CDESC_TYPE!()) != 0{
- unsafe {
- libc::puts("alias" as *const libc::c_char );
+
+ // #if defined (ALIAS)
+ alias = find_alias(command);
+ if (((dflags & CDESC_FORCE_PATH!()) == 0) && expand_aliases!=0 && alias != std::ptr::null_mut())
+ {
+ if (dflags & CDESC_TYPE!()) != 0{
+ unsafe {
+ libc::puts("alias" as *const libc::c_char );
+ }
}
- }
- else if (dflags & CDESC_SHORTDESC!()) != 0 {
- unsafe{
- println!("{:?} is aliased to {:?}\n",CStr::from_ptr(command), CStr::from_ptr(alias.value));
- }
- }
- else if dflags & CDESC_REUSABLE!(){
- unsafe {
- x = sh_single_quote((*alias).value);
- println!("alias {:?} = {:?}",CStr::from_ptr(command),CStr::from_ptr(x));
- libc::free(x);
- }
- }
- found = 1;
-
- if all == 0 {
- return 1;
- }
- }
-*/
+ else if (dflags & CDESC_SHORTDESC!()) != 0 {
+ unsafe{
+ println!("{:?} is aliased to {:?}\n",CStr::from_ptr(command), CStr::from_ptr(alias.value));
+ }
+ }
+ else if dflags & CDESC_REUSABLE!(){
+ unsafe {
+ x = sh_single_quote((*alias).value);
+ println!("alias {:?} = {:?}",CStr::from_ptr(command),CStr::from_ptr(x));
+ libc::free(x);
+ }
+ }
+ found = 1;
+
+ if all == 0 {
+ return 1;
+ }
+ }
+
/* Command is a shell reserved word? */
- if ((dflags & CDESC_FORCE_PATH!()) == 0) && unsafe {find_reserved_word(command)} >=0 {
+ if ((dflags & CDESC_FORCE_PATH!()) == 0) && unsafe { find_reserved_word(command) } >= 0 {
if dflags & CDESC_TYPE!() != 0 {
- unsafe{
+ unsafe {
let c_str_keyword = CString::new("keyword").unwrap();
libc::puts(c_str_keyword.as_ptr());
}
- }
- else if dflags & CDESC_SHORTDESC!() != 0 {
- unsafe{
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
+ unsafe {
let name = String::from("iskeyword");
- translation_fn(&name,command,std::ptr::null_mut());
+ translation_fn(&name, command, std::ptr::null_mut());
}
- }
- else if dflags & CDESC_REUSABLE!() != 0 {
+ } else if dflags & CDESC_REUSABLE!() != 0 {
unsafe {
- println! ("{:?}",CStr::from_ptr(command));
+ println!("{:?}", CStr::from_ptr(command));
}
}
found = 1;
- if all==0 {
+ if all == 0 {
return 1;
}
- }
-
- /* Command is a function? */
- if (dflags & (CDESC_FORCE_PATH!()|CDESC_NOFUNCS!()) == 0) && unsafe{find_function (command)}!= std::ptr::null_mut() {
- if dflags & CDESC_TYPE!() != 0 {
- unsafe {
- let c_str_function = CString::new("function").unwrap();
- libc::puts(c_str_function.as_ptr());
- }
- }
- else if dflags & CDESC_SHORTDESC!() != 0 {
- let mut result : *mut libc::c_char;
- unsafe {
- let name = String::from("isfunction");
- translation_fn(&name,command,std::ptr::null_mut());
- result = named_function_string (command, function_cell(find_function (command)), FUNC_MULTILINE!()|FUNC_EXTERNAL!());
- println!("{:?}",CStr::from_ptr(result));
- }
-
- }
- else if dflags & CDESC_REUSABLE!() != 0{
-
+ }
+
+ /* Command is a function? */
+ if (dflags & (CDESC_FORCE_PATH!() | CDESC_NOFUNCS!()) == 0)
+ && unsafe { find_function(command) } != std::ptr::null_mut()
+ {
+ if dflags & CDESC_TYPE!() != 0 {
unsafe {
- println!("{:?}",CStr::from_ptr(command));
+ let c_str_function = CString::new("function").unwrap();
+ libc::puts(c_str_function.as_ptr());
}
- }
-
- found = 1;
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
+ let result: *mut libc::c_char;
+ unsafe {
+ let name = String::from("isfunction");
+ translation_fn(&name, command, std::ptr::null_mut());
+ result = named_function_string(
+ command,
+ function_cell(find_function(command)),
+ FUNC_MULTILINE!() | FUNC_EXTERNAL!(),
+ );
+ println!("{:?}", CStr::from_ptr(result));
+ }
+ } else if dflags & CDESC_REUSABLE!() != 0 {
+ unsafe {
+ println!("{:?}", CStr::from_ptr(command));
+ }
+ }
- if all == 0{
- return 1;
- }
- }
+ found = 1;
- /* Command is a builtin? */
- if ((dflags & CDESC_FORCE_PATH!()) == 0) && unsafe{find_shell_builtin (command)}!= std::ptr::null_mut() {
- if dflags & CDESC_TYPE!() != 0{
- unsafe {
- let c_str_builtin = CString::new("builtin").unwrap();
- libc::puts(c_str_builtin.as_ptr());
+ if all == 0 {
+ return 1;
}
}
- else if dflags & CDESC_SHORTDESC!() != 0{
- if unsafe {posixly_correct}!= 0 && unsafe {find_special_builtin (command)} != std::ptr::null_mut() {
+
+ /* Command is a builtin? */
+ if ((dflags & CDESC_FORCE_PATH!()) == 0)
+ && unsafe { find_shell_builtin(command) } != std::ptr::null_mut()
+ {
+ if dflags & CDESC_TYPE!() != 0 {
unsafe {
- let name = String::from("special");
- translation_fn(&name,command,std::ptr::null_mut());
+ let c_str_builtin = CString::new("builtin").unwrap();
+ libc::puts(c_str_builtin.as_ptr());
}
-
- }
- else {
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
+ if unsafe { posixly_correct } != 0
+ && unsafe { find_special_builtin(command) } != std::ptr::null_mut()
+ {
+ unsafe {
+ let name = String::from("special");
+ translation_fn(&name, command, std::ptr::null_mut());
+ }
+ } else {
+ unsafe {
+ let name = String::from("isbuiltin");
+ translation_fn(&name, command, std::ptr::null_mut());
+ }
+ }
+ } else if dflags & CDESC_REUSABLE!() != 0 {
unsafe {
- let name = String::from("isbuiltin");
- translation_fn(&name,command,std::ptr::null_mut());
+ println!("{:?}", CStr::from_ptr(command));
}
}
- }
- else if dflags & CDESC_REUSABLE!() != 0 {
- unsafe {
- println!("{:?}",CStr::from_ptr(command));
+
+ found = 1;
+ if all == 0 {
+ return 1;
}
}
- found = 1;
- if all == 0{
- return 1;
- }
- }
-
- /* Command is a disk file? */
- /* If the command name given is already an absolute command, just
- check to see if it is executable. */
- if unsafe {absolute_program (command)} != 0 {
-
- f = unsafe {file_status (command)};
- if f & FS_EXECABLE!() != 0{
- if dflags & CDESC_TYPE!() != 0{
+ /* Command is a disk file? */
+ /* If the command name given is already an absolute command, just
+ check to see if it is executable. */
+ if unsafe { absolute_program(command) } != 0 {
+ f = unsafe { file_status(command) };
+ if f & FS_EXECABLE!() != 0 {
+ if dflags & CDESC_TYPE!() != 0 {
+ unsafe {
+ let c_str_file = CString::new("file").unwrap();
+ libc::puts(c_str_file.as_ptr());
+ }
+ }
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
unsafe {
- let c_str_file = CString::new("file").unwrap();
- libc::puts(c_str_file.as_ptr());
+ let name = String::from("is");
+ translation_fn(&name, command, command);
+ }
+ } else if dflags & (CDESC_REUSABLE!() | CDESC_PATH_ONLY!()) != 0 {
+ unsafe {
+ println!("{:?}", CStr::from_ptr(command));
}
+
+ /* There's no use looking in the hash table or in $PATH,
+ because they're not consulted when an absolute program
+ name is supplied. */
+ return 1;
}
- }
- else if dflags & CDESC_SHORTDESC!() != 0 {
- unsafe {
- let name = String::from("is");
- translation_fn(&name,command,command);
- }
- }
- else if dflags & (CDESC_REUSABLE!()|CDESC_PATH_ONLY!()) != 0{
- unsafe {
- println!("{:?}",CStr::from_ptr(command));
- }
-
- /* There's no use looking in the hash table or in $PATH,
- because they're not consulted when an absolute program
- name is supplied. */
- return 1;
- }
}
/* If the user isn't doing "-a", then we might care about
- whether the file is present in our hash table. */
- if all == 0 || (dflags & CDESC_FORCE_PATH!() != 0){
-
- full_path = unsafe{phash_search (command)};
- if full_path != std::ptr::null_mut(){
-
- if dflags & CDESC_TYPE!() != 0{
- unsafe{
- let c_str_file = CString::new("file").unwrap();
- libc::puts(c_str_file.as_ptr());
- }
- }
- else if dflags & CDESC_SHORTDESC!() != 0{
- unsafe{
- let name = String::from("hashed");
- translation_fn(&name,command,full_path);
- }
- }
- else if (dflags & (CDESC_REUSABLE!()|CDESC_PATH_ONLY!())) != 0{
- unsafe{
- println! ("{:?} ",CStr::from_ptr(full_path));
+ whether the file is present in our hash table. */
+ if all == 0 || (dflags & CDESC_FORCE_PATH!() != 0) {
+ full_path = unsafe { phash_search(command) };
+ if full_path != std::ptr::null_mut() {
+ if dflags & CDESC_TYPE!() != 0 {
+ unsafe {
+ let c_str_file = CString::new("file").unwrap();
+ libc::puts(c_str_file.as_ptr());
+ }
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
+ unsafe {
+ let name = String::from("hashed");
+ translation_fn(&name, command, full_path);
+ }
+ } else if (dflags & (CDESC_REUSABLE!() | CDESC_PATH_ONLY!())) != 0 {
+ unsafe {
+ println!("{:?} ", CStr::from_ptr(full_path));
+ }
+ }
+ unsafe {
+ libc::free(full_path as *mut c_void);
+ }
+ return 1;
}
}
- unsafe{
- libc::free (full_path as *mut c_void);
- }
- return 1;
- }
- }
- /* Now search through $PATH. */
- #[warn(while_true)]
- while true{
- if dflags & CDESC_STDPATH!() != 0 {
- /* command -p, all cannot be non-zero */
- unsafe{
- pathlist = conf_standard_path ();
- full_path = find_in_path (command, pathlist, FS_EXEC_PREFERRED!()|FS_NODIRS!());
+ /* Now search through $PATH. */
+ #[warn(while_true)]
+ loop {
+ if dflags & CDESC_STDPATH!() != 0 {
+ /* command -p, all cannot be non-zero */
+ unsafe {
+ pathlist = conf_standard_path();
+ full_path = find_in_path(command, pathlist, FS_EXEC_PREFERRED!() | FS_NODIRS!());
libc::free(pathlist as *mut c_void);
- }
- /* Will only go through this once, since all == 0 if STDPATH set */
-
- }
- else if all == 0{
- unsafe{
- full_path = find_user_command(command);
- }
-
- }
- else{
- unsafe {
- full_path = user_command_matches (command, FS_EXEC_ONLY!(), found_file); /* XXX - should that be FS_EXEC_PREFERRED? */
+ }
+ /* Will only go through this once, since all == 0 if STDPATH set */
+ } else if all == 0 {
+ unsafe {
+ full_path = find_user_command(command);
+ }
+ } else {
+ unsafe {
+ full_path = user_command_matches(command, FS_EXEC_ONLY!(), found_file);
+ /* XXX - should that be FS_EXEC_PREFERRED? */
+ }
}
-
- }
- if full_path == std::ptr::null_mut(){
- // return 0;
- break;
- }
-
- /* If we found the command as itself by looking through $PATH, it
- probably doesn't exist. Check whether or not the command is an
- executable file. If it's not, don't report a match. This is
- the default posix mode behavior */
- if (unsafe {STREQ!(full_path, command)} || unsafe {posixly_correct}!=0){
- unsafe{
- f = file_status (full_path);
+ if full_path == std::ptr::null_mut() {
+ // return 0;
+ break;
}
- if (f & FS_EXECABLE!() == 0){
+
+ /* If we found the command as itself by looking through $PATH, it
+ probably doesn't exist. Check whether or not the command is an
+ executable file. If it's not, don't report a match. This is
+ the default posix mode behavior */
+ if (unsafe { STREQ!(full_path, command) } || unsafe { posixly_correct } != 0) {
unsafe {
- libc::free (full_path as *mut c_void);
- full_path = std::ptr::null_mut() ;
+ f = file_status(full_path);
+ }
+ if f & FS_EXECABLE!() == 0 {
+ unsafe {
+ libc::free(full_path as *mut c_void);
+ full_path = std::ptr::null_mut();
+ }
+ if all == 0 {
+ break;
+ }
+ } else if ABSPATH!(full_path) {
+ }
+ /* placeholder; don't need to do anything yet */
+ else if dflags & (CDESC_REUSABLE!() | CDESC_PATH_ONLY!() | CDESC_SHORTDESC!()) != 0 {
+ if MP_DOCWD!() != 0 | (dflags & CDESC_ABSPATH!()) {
+ f = MP_RMDOT!();
+ } else {
+ f = 0;
+ }
+ unsafe {
+ x = sh_makepath(std::ptr::null_mut(), full_path, f);
+ libc::free(full_path as *mut c_void);
+ }
+
+ full_path = x;
}
- if all == 0{
- break;
- }
- }
- else if ABSPATH!(full_path){
- ;
- }
- /* placeholder; don't need to do anything yet */
- else if dflags & (CDESC_REUSABLE!()|CDESC_PATH_ONLY!()|CDESC_SHORTDESC!()) != 0{
- if MP_DOCWD!()!=0 | (dflags & CDESC_ABSPATH!()) {
- f=MP_RMDOT!();
- }
- else {
- f=0;
- }
- unsafe {
- x = sh_makepath ( std::ptr::null_mut() , full_path, f);
- libc::free (full_path as *mut c_void);
- }
-
- full_path = x;
- }
- }
- /* If we require a full path and don't have one, make one */
- else if ((dflags & CDESC_ABSPATH!())!= 0) && ABSPATH!(full_path) == false {
- unsafe {
- x = sh_makepath ( std::ptr::null_mut() , full_path, MP_DOCWD!()|MP_RMDOT!());
- libc::free (full_path as *mut c_void);
}
- full_path = x;
- }
- found_file += 1;
- found = 1;
- if dflags & CDESC_TYPE!() != 0{
- unsafe {
- let c_str_file = CString::new("file").unwrap();
- libc::puts(c_str_file.as_ptr());
- }
- }
- else if dflags & CDESC_SHORTDESC!() != 0{
- unsafe{
- let name = String::from("is");
- translation_fn(&name,command,full_path);
+ /* If we require a full path and don't have one, make one */
+ else if ((dflags & CDESC_ABSPATH!()) != 0) && ABSPATH!(full_path) == false {
+ unsafe {
+ x = sh_makepath(std::ptr::null_mut(), full_path, MP_DOCWD!() | MP_RMDOT!());
+ libc::free(full_path as *mut c_void);
+ }
+ full_path = x;
}
-
- }
- else if dflags & (CDESC_REUSABLE!()|CDESC_PATH_ONLY!()) != 0{
- unsafe{
- println! ("{:?}", CStr::from_ptr(full_path));
+ found_file += 1;
+ found = 1;
+ if dflags & CDESC_TYPE!() != 0 {
+ unsafe {
+ let c_str_file = CString::new("file").unwrap();
+ libc::puts(c_str_file.as_ptr());
+ }
+ } else if dflags & CDESC_SHORTDESC!() != 0 {
+ unsafe {
+ let name = String::from("is");
+ translation_fn(&name, command, full_path);
+ }
+ } else if dflags & (CDESC_REUSABLE!() | CDESC_PATH_ONLY!()) != 0 {
+ unsafe {
+ println!("{:?}", CStr::from_ptr(full_path));
+ }
}
-
- }
- unsafe {
- libc::free (full_path as *mut c_void);
- }
- full_path = std::ptr::null_mut() ;
- if all == 0{
- break;
- }
-
+ unsafe {
+ libc::free(full_path as *mut c_void);
+ }
+ full_path = std::ptr::null_mut();
+ if all == 0 {
+ break;
+ }
}
- found
+ found
}
-unsafe fn translation_fn (command:&String,args1 : *mut libc::c_char,args2 : *mut libc::c_char) {
+unsafe fn translation_fn(command: &String, args1: *mut libc::c_char, args2: *mut libc::c_char) {
let mgr = ResourceManager::new("/usr/share/utshell/resources/{locale}/{res_id}".into());
- let resources = vec![ "message.ftl".into()];
+ let resources = vec!["message.ftl".into()];
let mut args = FluentArgs::new();
- if args1 != std::ptr::null_mut(){
- args.set("str1",format!("{:?}",CStr::from_ptr(args1).to_str().unwrap()));
+ if args1 != std::ptr::null_mut() {
+ args.set(
+ "str1",
+ format!("{:?}", CStr::from_ptr(args1).to_str().unwrap()),
+ );
}
- if args2 != std::ptr::null_mut(){
- args.set("str2",format!("{:?}",CStr::from_ptr(args2).to_str().unwrap()));
+ if args2 != std::ptr::null_mut() {
+ args.set(
+ "str2",
+ format!("{:?}", CStr::from_ptr(args2).to_str().unwrap()),
+ );
}
let bundle = mgr.get_bundle(get_local_str(), resources);
- let mut value = bundle.get_message(command).unwrap();
- let mut pattern = value.value().expect("partern err");
+ let value = bundle.get_message(command).unwrap();
+ let pattern = value.value().expect("partern err");
let mut errors = vec![];
- if args1 != std::ptr::null_mut(){
- let mut msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
+ if args1 != std::ptr::null_mut() {
+ let msg1 = bundle.format_pattern(&pattern, Some(&args), &mut errors);
println!("{msg1}");
- }
- else{
- let mut msg1 = bundle.format_pattern(&pattern, None, &mut errors);
+ } else {
+ let msg1 = bundle.format_pattern(&pattern, None, &mut errors);
println!("{msg1}");
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/bash-5.1/builtins_rust/ulimit/src/lib.rs b/bash-5.1/builtins_rust/ulimit/src/lib.rs
index bfc018164c9ed2d56528676f5070733a33ce71e8..997e7000a6cef30c68a71df02d07e42202741fee 100644
--- a/bash-5.1/builtins_rust/ulimit/src/lib.rs
+++ b/bash-5.1/builtins_rust/ulimit/src/lib.rs
@@ -1,15 +1,13 @@
-//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
+//# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//# SPDX-License-Identifier: GPL-3.0-or-later
-extern crate libc;
+extern crate libc;
extern crate nix;
use std::ffi::CStr;
use std::ffi::CString;
-use std::fmt::format;
-use std::ptr;
-use std::mem;
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage};
+
+use rcommon::{WordList, EXECUTION_FAILURE, EXECUTION_SUCCESS, EX_USAGE};
use rhelp::r_builtin_help;
#[derive(Copy, Clone)]
@@ -19,167 +17,162 @@ pub struct rlimit {
pub rlim_max: rlim_t,
}
-
-#[repr (C)]
-#[derive(Copy,Clone)]
-pub struct RESOURCE_LIMITS{
- option : i32, /* The ulimit option for this limit. */
- parameter : i32, /* Parameter to pass to get_limit (). */
- block_factor : i32, /* Blocking factor for specific limit. */
- description : *const libc::c_char, /* Descriptive string to output. */
- units : *const libc::c_char /* scale */
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct RESOURCE_LIMITS {
+ option: i32, /* The ulimit option for this limit. */
+ parameter: i32, /* Parameter to pass to get_limit (). */
+ block_factor: i32, /* Blocking factor for specific limit. */
+ description: *const libc::c_char, /* Descriptive string to output. */
+ units: *const libc::c_char, /* scale */
}
-#[repr (C)]
-#[derive(Copy,Clone)]
+#[repr(C)]
+#[derive(Copy, Clone)]
pub struct _cmd {
- cmd : i32,
- arg : *mut libc::c_char
-}
+ cmd: i32,
+ arg: *mut libc::c_char,
+}
-#[repr (C)]
-#[derive(Copy,Clone)]
+#[repr(C)]
+#[derive(Copy, Clone)]
/* Information about the current user. */
pub struct user_info {
- uid : uid_t,
- euid : uid_t,
- gid : gid_t,
- egid : gid_t,
- user_name : *mut libc::c_char,
- shell :*mut libc::c_char,
- home_dir : *mut libc::c_char
+ uid: uid_t,
+ euid: uid_t,
+ gid: gid_t,
+ egid: gid_t,
+ user_name: *mut libc::c_char,
+ shell: *mut libc::c_char,
+ home_dir: *mut libc::c_char,
}
#[macro_export]
-macro_rules! SIZEOFLIMIT{
+macro_rules! SIZEOFLIMIT {
() => {
- std::mem::size_of::() as usize
- }
+ std::mem::size_of::() as usize
+ };
}
#[macro_export]
-macro_rules! SIZEOFLIMITS{
+macro_rules! SIZEOFLIMITS {
() => {
- SIZEOFLIMIT!() *18
- }
+ SIZEOFLIMIT!() * 18
+ };
}
#[macro_export]
-macro_rules! SIZEOFULCMD{
+macro_rules! SIZEOFULCMD {
() => {
std::mem::size_of::()
- }
+ };
}
#[macro_export]
-macro_rules! LIMIT_HARD{
+macro_rules! LIMIT_HARD {
() => {
- 0x01
- }
+ 0x01
+ };
}
#[macro_export]
-macro_rules! LIMIT_SOFT{
+macro_rules! LIMIT_SOFT {
() => {
- 0x02
- }
+ 0x02
+ };
}
-
#[macro_export]
-macro_rules! POSIXBLK{
+macro_rules! POSIXBLK {
() => {
- -2
- }
+ -2
+ };
}
#[macro_export]
-macro_rules! BLOCKSIZE{
+macro_rules! BLOCKSIZE {
($s:expr) => {
if $s == POSIXBLK!() {
- if unsafe{posixly_correct}!= 0 {
+ if unsafe { posixly_correct } != 0 {
512
- }
- else {
+ } else {
1024
}
- }
- else {
+ } else {
$s
- }
- }
+ }
+ };
}
#[macro_export]
-macro_rules! RLIM_SAVED_MAX{
+macro_rules! RLIM_SAVED_MAX {
() => {
RLIM_INFINITY!();
- }
+ };
}
-
#[deny(missing_fragment_specifier)]
#[macro_export]
-macro_rules! STREQ{
- ($a:expr,$b:expr) =>{
- $a==$b && libc::strcmp($a,$b)==0
- }
+macro_rules! STREQ {
+ ($a:expr,$b:expr) => {
+ $a == $b && libc::strcmp($a, $b) == 0
+ };
}
#[macro_export]
-macro_rules! NCMDS {
+macro_rules! NCMDS {
() => {
- SIZEOFLIMITS!() / SIZEOFLIMIT!()
- }
+ SIZEOFLIMITS!() / SIZEOFLIMIT!()
+ };
}
#[macro_export]
-macro_rules! RLIMIT_FILESIZE {
+macro_rules! RLIMIT_FILESIZE {
() => {
1
- }
+ };
}
#[macro_export]
macro_rules! RLIMIT_PIPESIZE {
- () => {
+ () => {
257
- }
+ };
}
#[macro_export]
macro_rules! PIPESIZE {
- () => {
+ () => {
4096
- }
+ };
}
#[macro_export]
macro_rules! PIPE_BUF {
- () => {
+ () => {
PIPESIZE!()
- }
+ };
}
#[macro_export]
-macro_rules! RLIMIT_OPENFILES{
+macro_rules! RLIMIT_OPENFILES {
() => {
7
- }
+ };
}
#[macro_export]
-macro_rules! RLIMIT_VIRTMEM{
+macro_rules! RLIMIT_VIRTMEM {
() => {
9
- }
+ };
}
#[macro_export]
-macro_rules! RLIMIT_MAXUPROC{
+macro_rules! RLIMIT_MAXUPROC {
() => {
6
- }
+ };
}
#[macro_export]
@@ -187,19 +180,19 @@ macro_rules! RLIM_INFINITY {
() => {
-1
//0x7fffffff
- }
+ };
}
#[macro_export]
-macro_rules! RLIM_SAVED_CUR{
+macro_rules! RLIM_SAVED_CUR {
() => {
RLIM_INFINITY!()
- }
+ };
}
-type RLIMTYPE = i64;
-type RESOURCE_LIMITS_T= RESOURCE_LIMITS;
-type ULCMD = _cmd;
+type RLIMTYPE = i64;
+type RESOURCE_LIMITS_T = RESOURCE_LIMITS;
+type ULCMD = _cmd;
pub type __rlimit_resource = libc::c_uint;
pub const __RLIM_NLIMITS: __rlimit_resource = 16;
pub const __RLIMIT_NLIMITS: __rlimit_resource = 16;
@@ -228,51 +221,54 @@ pub type __gid_t = i32;
pub type gid_t = __gid_t;
pub type uid_t = __uid_t;
-static mut cmdlistsz : i32 = 0;
-
-const limits: [ RESOURCE_LIMITS_T;18] =[
-
- { RESOURCE_LIMITS {
- option: 'R' as i32,
- parameter: __RLIMIT_RTTIME as i32,
- block_factor: 1 as i32,
- description: b"real-time non-blocking time\0" as *const u8
- as *const libc::c_char,
- units: b"microseconds\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'c' as i32,
- parameter: RLIMIT_CORE as i32,
- block_factor: -(2 as i32),
- description: b"core file size\0" as *const u8 as *const libc::c_char,
- units: b"blocks\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'd' as i32,
- parameter: RLIMIT_DATA as i32,
- block_factor: 1024 as i32,
- description: b"data seg size\0" as *const u8 as *const libc::c_char,
- units: b"kbytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'e' as i32,
- parameter: __RLIMIT_NICE as i32,
- block_factor: 1 as i32,
- description: b"scheduling priority\0" as *const u8 as *const libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'f' as i32,
- parameter: RLIMIT_FSIZE as i32,
- block_factor: -(2 as i32),
- description: b"file size\0" as *const u8 as *const libc::c_char,
- units: b"blocks\0" as *const u8 as *const libc::c_char,
- }},
-
+static mut cmdlistsz: i32 = 0;
+
+const limits: [RESOURCE_LIMITS_T; 18] = [
+ {
+ RESOURCE_LIMITS {
+ option: 'R' as i32,
+ parameter: __RLIMIT_RTTIME as i32,
+ block_factor: 1 as i32,
+ description: b"real-time non-blocking time\0" as *const u8 as *const libc::c_char,
+ units: b"microseconds\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'c' as i32,
+ parameter: RLIMIT_CORE as i32,
+ block_factor: -(2 as i32),
+ description: b"core file size\0" as *const u8 as *const libc::c_char,
+ units: b"blocks\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'd' as i32,
+ parameter: RLIMIT_DATA as i32,
+ block_factor: 1024 as i32,
+ description: b"data seg size\0" as *const u8 as *const libc::c_char,
+ units: b"kbytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'e' as i32,
+ parameter: __RLIMIT_NICE as i32,
+ block_factor: 1 as i32,
+ description: b"scheduling priority\0" as *const u8 as *const libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'f' as i32,
+ parameter: RLIMIT_FSIZE as i32,
+ block_factor: -(2 as i32),
+ description: b"file size\0" as *const u8 as *const libc::c_char,
+ units: b"blocks\0" as *const u8 as *const libc::c_char,
+ }
+ },
{
RESOURCE_LIMITS {
option: 'i' as i32,
@@ -282,104 +278,115 @@ const limits: [ RESOURCE_LIMITS_T;18] =[
units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
}
},
-
- { RESOURCE_LIMITS {
- option: 'l' as i32,
- parameter: __RLIMIT_MEMLOCK as i32,
- block_factor: 1024 as i32,
- description: b"max locked memory\0" as *const u8 as *const libc::c_char,
- units: b"kbytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'm' as i32,
- parameter: __RLIMIT_RSS as i32,
- block_factor: 1024 as i32,
- description: b"max memory size\0" as *const u8 as *const libc::c_char,
- units: b"kbytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'n' as i32,
- parameter: RLIMIT_NOFILE as i32,
- block_factor: 1 as i32,
- description: b"open files\0" as *const u8 as *const libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'p' as i32,
- parameter: 257 as i32,
- block_factor: 512 as i32,
- description: b"pipe size\0" as *const u8 as *const libc::c_char,
- units: b"512 bytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'q' as i32,
- parameter: __RLIMIT_MSGQUEUE as i32,
- block_factor: 1 as i32,
- description: b"POSIX message queues\0" as *const u8 as *const libc::c_char,
- units: b"bytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'r' as i32,
- parameter: __RLIMIT_RTPRIO as i32,
- block_factor: 1 as i32,
- description: b"real-time priority\0" as *const u8 as *const libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 's' as i32,
- parameter: RLIMIT_STACK as i32,
- block_factor: 1024 as i32,
- description: b"stack size\0" as *const u8 as *const libc::c_char,
- units: b"kbytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 't' as i32,
- parameter: RLIMIT_CPU as i32,
- block_factor: 1 as i32,
- description: b"cpu time\0" as *const u8 as *const libc::c_char,
- units: b"seconds\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'u' as i32,
- parameter: __RLIMIT_NPROC as i32,
- block_factor: 1 as i32,
- description: b"max user processes\0" as *const u8 as *const libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'v' as i32,
- parameter: RLIMIT_AS as i32,
- block_factor: 1024 as i32,
- description: b"virtual memory\0" as *const u8 as *const libc::c_char,
- units: b"kbytes\0" as *const u8 as *const libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: 'x' as i32,
- parameter: __RLIMIT_LOCKS as i32,
- block_factor: 1 as i32,
- description: b"file locks\0" as *const u8 as *const libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }},
-
- { RESOURCE_LIMITS {
- option: -1 ,
- parameter: -1,
- block_factor:-1,
- description: 0 as *const libc::c_void as *mut libc::c_void
- as *mut libc::c_char,
- units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
- }}
- ];
+ {
+ RESOURCE_LIMITS {
+ option: 'l' as i32,
+ parameter: __RLIMIT_MEMLOCK as i32,
+ block_factor: 1024 as i32,
+ description: b"max locked memory\0" as *const u8 as *const libc::c_char,
+ units: b"kbytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'm' as i32,
+ parameter: __RLIMIT_RSS as i32,
+ block_factor: 1024 as i32,
+ description: b"max memory size\0" as *const u8 as *const libc::c_char,
+ units: b"kbytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'n' as i32,
+ parameter: RLIMIT_NOFILE as i32,
+ block_factor: 1 as i32,
+ description: b"open files\0" as *const u8 as *const libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'p' as i32,
+ parameter: 257 as i32,
+ block_factor: 512 as i32,
+ description: b"pipe size\0" as *const u8 as *const libc::c_char,
+ units: b"512 bytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'q' as i32,
+ parameter: __RLIMIT_MSGQUEUE as i32,
+ block_factor: 1 as i32,
+ description: b"POSIX message queues\0" as *const u8 as *const libc::c_char,
+ units: b"bytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'r' as i32,
+ parameter: __RLIMIT_RTPRIO as i32,
+ block_factor: 1 as i32,
+ description: b"real-time priority\0" as *const u8 as *const libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 's' as i32,
+ parameter: RLIMIT_STACK as i32,
+ block_factor: 1024 as i32,
+ description: b"stack size\0" as *const u8 as *const libc::c_char,
+ units: b"kbytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 't' as i32,
+ parameter: RLIMIT_CPU as i32,
+ block_factor: 1 as i32,
+ description: b"cpu time\0" as *const u8 as *const libc::c_char,
+ units: b"seconds\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'u' as i32,
+ parameter: __RLIMIT_NPROC as i32,
+ block_factor: 1 as i32,
+ description: b"max user processes\0" as *const u8 as *const libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'v' as i32,
+ parameter: RLIMIT_AS as i32,
+ block_factor: 1024 as i32,
+ description: b"virtual memory\0" as *const u8 as *const libc::c_char,
+ units: b"kbytes\0" as *const u8 as *const libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: 'x' as i32,
+ parameter: __RLIMIT_LOCKS as i32,
+ block_factor: 1 as i32,
+ description: b"file locks\0" as *const u8 as *const libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+ {
+ RESOURCE_LIMITS {
+ option: -1,
+ parameter: -1,
+ block_factor: -1,
+ description: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ units: 0 as *const libc::c_void as *mut libc::c_void as *mut libc::c_char,
+ }
+ },
+];
extern "C" {
fn reset_internal_getopt();
@@ -390,39 +397,36 @@ extern "C" {
fn internal_getopt(_: *mut WordList, _: *mut libc::c_char) -> i32;
fn strerror(_: i32) -> *mut libc::c_char;
fn sprintf(_: *mut libc::c_char, _: *const libc::c_char, _: ...) -> i32;
- fn string_to_rlimtype(_: *mut libc::c_char ) -> rlim_t;
+ fn string_to_rlimtype(_: *mut libc::c_char) -> rlim_t;
fn getdtablesize() -> i32;
fn builtin_usage();
- fn sh_erange (s:* mut libc::c_char, desc:* mut libc::c_char);
+ fn sh_erange(s: *mut libc::c_char, desc: *mut libc::c_char);
fn sh_invalidnum(arg1: *mut libc::c_char);
fn __errno_location() -> *mut i32;
fn getrlimit(__resource: __rlimit_resource_t, __rlimits: *mut rlimit) -> i32;
- fn setrlimit(
- __resource: __rlimit_resource_t,
- __rlimits: *const rlimit,
- ) -> i32;
+ fn setrlimit(__resource: __rlimit_resource_t, __rlimits: *const rlimit) -> i32;
fn builtin_error(_: *const libc::c_char, _: ...);
fn getmaxchild() -> i64;
-
+
static mut loptend: *mut WordList;
static mut list_optarg: *mut libc::c_char;
- static mut posixly_correct:i32 ;
+ static mut posixly_correct: i32;
static mut current_user: user_info;
}
-static mut optstring:[ libc::c_char;4 + 2 * NCMDS!() as usize] = [0;4 + 2 * NCMDS!() as usize];
-static mut cmdlist : *mut ULCMD = 0 as *const ULCMD as *mut ULCMD;
-static mut ncmd : i32 = 0;
+static mut optstring: [libc::c_char; 4 + 2 * NCMDS!() as usize] = [0; 4 + 2 * NCMDS!() as usize];
+static mut cmdlist: *mut ULCMD = 0 as *const ULCMD as *mut ULCMD;
+static mut ncmd: i32 = 0;
-fn _findlim (opt:i32) -> i32{
- // let mut register : i32;
+fn _findlim(opt: i32) -> i32 {
+ // let mut register : i32;
//let i : i32 = 0;
for i in 0..17 {
- if limits[i].option > 0{
- if limits[i].option == opt {
- return i as i32;
+ if limits[i].option > 0 {
+ if limits[i].option == opt {
+ return i as i32;
}
}
}
@@ -430,55 +434,60 @@ fn _findlim (opt:i32) -> i32{
}
#[no_mangle]
-pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{
-
- let mut s : *mut libc::c_char;
- let mut c : i32 ;
- let mut limind : i32 ;
- let mut mode : i32 = 0 ;
- let mut opt : i32 = 0 ;
- let mut all_limits : i32 = 0 ;
+pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32 {
+ let mut s: *mut libc::c_char;
+ let c: i32;
+ let mut limind: i32;
+ let mut mode: i32 = 0;
+ let mut opt: i32 = 0;
+ let mut all_limits: i32 = 0;
if optstring[0] == 0 {
- s = optstring.as_mut_ptr();
- s = s.offset(0);
- *s = 'a' as libc::c_char;
- s = s.offset(1);
- *s = 'S' as libc::c_char;
- s = s.offset(1);
- *s = 'H' as libc::c_char;
- s = s.offset(1);
- c = 0 ;
+ s = optstring.as_mut_ptr();
+ s = s.offset(0);
+ *s = 'a' as libc::c_char;
+ s = s.offset(1);
+ *s = 'S' as libc::c_char;
+ s = s.offset(1);
+ *s = 'H' as libc::c_char;
+ s = s.offset(1);
+ c = 0;
for i in 0..17 {
- if limits[i].option > 0{
+ if limits[i].option > 0 {
*s = limits[i].option as libc::c_char;
- s = s.offset(1);
- *s = ';' as libc::c_char;
- s = s.offset(1);
- }
+ s = s.offset(1);
+ *s = ';' as libc::c_char;
+ s = s.offset(1);
+ }
}
- *s = '\0' as libc::c_char;
+ *s = '\0' as libc::c_char;
}
- if cmdlistsz == 0{
- cmdlistsz = 16;
+ if cmdlistsz == 0 {
+ cmdlistsz = 16;
unsafe {
- cmdlist =
- xmalloc ((cmdlistsz as u64)*(std::mem::size_of::() as libc::c_ulong) ) as *mut ULCMD;
+ cmdlist = xmalloc((cmdlistsz as u64) * (std::mem::size_of::() as libc::c_ulong))
+ as *mut ULCMD;
}
}
ncmd = 0;
- reset_internal_getopt ();
+ reset_internal_getopt();
opt = internal_getopt(list, optstring.as_ptr() as *mut libc::c_char);
while opt != -1 {
- let optu8:u8= opt as u8;
- let optChar:char=char::from(optu8);
+ let optu8: u8 = opt as u8;
+ let optChar: char = char::from(optu8);
match optChar {
- 'a' => { all_limits = all_limits + 1 ;}
- 'S' => { mode = mode | LIMIT_SOFT!() ; }
- 'H' => { mode = mode | LIMIT_HARD!();}
- '?'=> {
- builtin_usage();
- return EX_USAGE;
+ 'a' => {
+ all_limits = all_limits + 1;
+ }
+ 'S' => {
+ mode = mode | LIMIT_SOFT!();
+ }
+ 'H' => {
+ mode = mode | LIMIT_HARD!();
+ }
+ '?' => {
+ builtin_usage();
+ return EX_USAGE;
}
_ => {
if opt == -99 {
@@ -486,9 +495,11 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{
return EX_USAGE;
}
if ncmd >= cmdlistsz {
- cmdlistsz = cmdlistsz * 2 ;
+ cmdlistsz = cmdlistsz * 2;
cmdlist = xrealloc(
- cmdlist as *mut libc::c_void,(cmdlistsz as u64) * std::mem::size_of::() as u64 ) as *mut ULCMD;
+ cmdlist as *mut libc::c_void,
+ (cmdlistsz as u64) * std::mem::size_of::() as u64,
+ ) as *mut ULCMD;
}
unsafe {
(*cmdlist.offset(ncmd as isize)).cmd = opt;
@@ -496,7 +507,7 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{
//ncmd = ncmd + 1;
let ref mut fresh6 = (*cmdlist.offset(fresh5 as isize)).arg;
*fresh6 = list_optarg;
- // let mut cmm =&mut (*((cmdlist as usize +
+ // let mut cmm =&mut (*((cmdlist as usize +
// (ncmd as usize)*std::mem::size_of::())as *mut ULCMD) as ULCMD);
// cmm.cmd = opt;
// cmm.arg = list_optarg;
@@ -504,225 +515,221 @@ pub unsafe extern "C" fn r_ulimit_builtin(mut list: *mut WordList) -> i32{
// as *mut ULCMD) as ULCMD).cmd = opt ;
// (*((cmdlist as usize + (ncmd as usize) * std::mem::size_of::())
// as *mut ULCMD) as ULCMD).arg = list_optarg;
- ncmd = ncmd+1;
- }
-
+ ncmd = ncmd + 1;
+ }
}
}
- opt = internal_getopt (list, optstring.as_ptr() as * mut libc::c_char);
- }
+ opt = internal_getopt(list, optstring.as_ptr() as *mut libc::c_char);
+ }
// as *mut ULCMD) as ULCMD).cmd );
list = loptend;
- if all_limits != 0 {
- if mode == 0 {
- print_all_limits (LIMIT_SOFT!());
- }
- else {
- print_all_limits (mode);
- }
- return sh_chkwrite(EXECUTION_SUCCESS!());
- }
-
- if ncmd == 0 {
- unsafe {
- (*cmdlist.offset(ncmd as isize)).cmd = 'f' as i32;
- // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
- // cmm.cmd = 'f' as i32;
- }
- /* `ulimit something' is same as `ulimit -f something' */
- if !list.is_null() {
- unsafe {
- (*cmdlist.offset(ncmd as isize)).arg = (*(*list).word).word;
- // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
- // cmm.arg = (*(*list).word).word;
- ncmd = ncmd+1;
- }
- }
- else {
+ if all_limits != 0 {
+ if mode == 0 {
+ print_all_limits(LIMIT_SOFT!());
+ } else {
+ print_all_limits(mode);
+ }
+ return sh_chkwrite(EXECUTION_SUCCESS!());
+ }
+
+ if ncmd == 0 {
+ unsafe {
+ (*cmdlist.offset(ncmd as isize)).cmd = 'f' as i32;
+ // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
+ // cmm.cmd = 'f' as i32;
+ }
+ /* `ulimit something' is same as `ulimit -f something' */
+ if !list.is_null() {
+ unsafe {
+ (*cmdlist.offset(ncmd as isize)).arg = (*(*list).word).word;
+ // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
+ // cmm.arg = (*(*list).word).word;
+ ncmd = ncmd + 1;
+ }
+ } else {
unsafe {
- (*cmdlist.offset(ncmd as isize)).arg = std::ptr::null_mut();
- // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
- // cmm.arg = std::ptr::null_mut();
- ncmd = ncmd+1;
+ (*cmdlist.offset(ncmd as isize)).arg = std::ptr::null_mut();
+ // let mut cmm = *((cmdlist as usize + (ncmd as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
+ // cmm.arg = std::ptr::null_mut();
+ ncmd = ncmd + 1;
+ }
}
+ if !list.is_null() {
+ list = (*list).next;
+ }
+ }
+ for d in 0..ncmd {
+ //as *mut ULCMD) as ULCMD).cmd);
+ let cmm = *((cmdlist as usize + (d as usize) * std::mem::size_of::()) as *mut ULCMD)
+ as ULCMD;
+ let _dmd = cmm.cmd;
+
+ limind = _findlim((*cmdlist.offset(d as isize)).cmd);
+ if limind == -1 {
+ unsafe {
+ builtin_error(
+ b"%s: bad command : %s\0" as *const u8 as *const libc::c_char,
+ (*cmdlist.offset(d as isize)).cmd,
+ strerror(*__errno_location()) as *const libc::c_char,
+ );
+ }
+ return EX_USAGE;
+ }
}
- if !list.is_null() {
- list = (*list).next;
+
+ for d in 0..ncmd {
+ let dmd = (*cmdlist.offset(d as isize)).cmd;
+ let drg = (*cmdlist.offset(d as isize)).arg;
+ // let dmd = (*((cmdlist as usize + (d as usize )*std::mem::size_of::())
+ // as *mut ULCMD) as ULCMD).cmd;
+ // let drg = (*((cmdlist as usize + (d as usize )*std::mem::size_of::())
+ // as *mut ULCMD) as ULCMD).arg;
+ if (ulimit_internal(dmd, drg, mode, d - 1)) == EXECUTION_FAILURE!() {
+ return EXECUTION_FAILURE!();
+ }
}
- }
+ return EXECUTION_SUCCESS!();
+}
- for d in 0..ncmd {
- //as *mut ULCMD) as ULCMD).cmd);
- let cmm = *((cmdlist as usize + (d as usize )*std::mem::size_of::())as *mut ULCMD) as ULCMD;
- let dmd = cmm.cmd;
+unsafe fn ulimit_internal(
+ cmd: i32,
+ cmdarg: *mut libc::c_char,
+ mut mode: i32,
+ multiple: i32,
+) -> i32 {
+ let opt: i32;
+ let limind: i32;
+ let setting: i32;
+ let block_factor: i32;
+ let mut soft_limit: RLIMTYPE = 0;
+ let mut hard_limit: RLIMTYPE = 0;
+ let mut real_limit: RLIMTYPE = 0;
+ let limit: RLIMTYPE;
- limind = _findlim ((*cmdlist.offset(d as isize)).cmd);
- if limind == -1 {
- unsafe {
- builtin_error(b"%s: bad command : %s\0" as *const u8 as *const libc::c_char,
- (*cmdlist.offset(d as isize)).cmd,
- strerror(*__errno_location()) as *const libc::c_char);
- }
- return EX_USAGE;
- }
- }
-
- for d in 0..ncmd {
- let dmd = (*cmdlist.offset(d as isize)).cmd;
- let drg = (*cmdlist.offset(d as isize)).arg;
- // let dmd = (*((cmdlist as usize + (d as usize )*std::mem::size_of::())
- // as *mut ULCMD) as ULCMD).cmd;
- // let drg = (*((cmdlist as usize + (d as usize )*std::mem::size_of::())
- // as *mut ULCMD) as ULCMD).arg;
- if (ulimit_internal (dmd,drg, mode, d-1)) == EXECUTION_FAILURE!() {
- return EXECUTION_FAILURE!();
- }
- }
- return EXECUTION_SUCCESS!();
-
-}
-
-unsafe fn ulimit_internal (cmd : i32 , cmdarg :*mut libc::c_char,mut mode : i32, multiple : i32) -> i32 {
- let mut opt : i32 ;
- let mut limind : i32 ;
- let mut setting : i32 ;
- let mut block_factor : i32 ;
- let mut soft_limit : RLIMTYPE = 0;
- let mut hard_limit : RLIMTYPE =0;
- let mut real_limit : RLIMTYPE = 0;
- let mut limit : RLIMTYPE;
-
if cmdarg != std::ptr::null_mut() {
setting = 1;
- }
- else {
+ } else {
setting = 0;
}
limind = _findlim(cmd);
if mode == 0 {
if setting != 0 {
- mode = LIMIT_HARD!()|LIMIT_SOFT!();
- }
- else {
+ mode = LIMIT_HARD!() | LIMIT_SOFT!();
+ } else {
mode = LIMIT_SOFT!();
}
}
- opt = get_limit (limind, &mut soft_limit, &mut hard_limit);
+ opt = get_limit(limind, &mut soft_limit, &mut hard_limit);
- if opt < 0 {
- unsafe {
- builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char, limits[limind as usize].description,
- strerror(*__errno_location()) as *const libc::c_char);
+ if opt < 0 {
+ unsafe {
+ builtin_error(
+ b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char,
+ limits[limind as usize].description,
+ strerror(*__errno_location()) as *const libc::c_char,
+ );
+ }
+
+ return EXECUTION_FAILURE!();
}
-
- return EXECUTION_FAILURE!();
- }
-
- if setting == 0 {
- if (mode & LIMIT_SOFT!()) != 0 {
- printone (limind,soft_limit,multiple);
- }
- else {
- printone (limind,hard_limit,multiple);
- }
- return EXECUTION_SUCCESS!();
- }
-
- let mut c_str_hard = CString::new("hard").unwrap();
- let mut c_str_soft = CString::new("soft").unwrap();
- let mut c_str_unlimited = CString::new("unlimited").unwrap();
- if unsafe{STREQ!(cmdarg,c_str_hard.as_ptr() as *mut libc::c_char )}{
- real_limit = hard_limit;
- }
-
- else if unsafe{STREQ!(cmdarg, c_str_soft.as_ptr() as *mut libc::c_char)}{
- real_limit = soft_limit;
- }
- else if unsafe{STREQ!(cmdarg, c_str_unlimited.as_ptr() as *mut libc::c_char)}{
- real_limit = RLIM_INFINITY!();
- }
-
- else if unsafe {all_digits(cmdarg)} !=0 {
- limit = unsafe {string_to_rlimtype (cmdarg) as i64};
- block_factor = BLOCKSIZE!(limits[limind as usize].block_factor);
- real_limit = limit * block_factor as i64;
-
- if (real_limit / block_factor as i64) != limit {
- let c_str_limit =CString::new("limit").unwrap();
- unsafe {sh_erange (cmdarg,c_str_limit.as_ptr() as *mut libc::c_char)};
- return EXECUTION_FAILURE!();
- }
- }
-
- else {
- sh_invalidnum (cmdarg);
- return EXECUTION_FAILURE!();
- }
- if set_limit (limind, real_limit, mode) < 0 {
- builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char, limits[limind as usize].description,
- strerror(*__errno_location()) as *const libc::c_char);
- return EXECUTION_FAILURE!();
+
+ if setting == 0 {
+ if (mode & LIMIT_SOFT!()) != 0 {
+ printone(limind, soft_limit, multiple);
+ } else {
+ printone(limind, hard_limit, multiple);
+ }
+ return EXECUTION_SUCCESS!();
+ }
+
+ let c_str_hard = CString::new("hard").unwrap();
+ let c_str_soft = CString::new("soft").unwrap();
+ let c_str_unlimited = CString::new("unlimited").unwrap();
+ if unsafe { STREQ!(cmdarg, c_str_hard.as_ptr() as *mut libc::c_char) } {
+ real_limit = hard_limit;
+ } else if unsafe { STREQ!(cmdarg, c_str_soft.as_ptr() as *mut libc::c_char) } {
+ real_limit = soft_limit;
+ } else if unsafe { STREQ!(cmdarg, c_str_unlimited.as_ptr() as *mut libc::c_char) } {
+ real_limit = RLIM_INFINITY!();
+ } else if unsafe { all_digits(cmdarg) } != 0 {
+ limit = unsafe { string_to_rlimtype(cmdarg) as i64 };
+ block_factor = BLOCKSIZE!(limits[limind as usize].block_factor);
+ real_limit = limit * block_factor as i64;
+
+ if (real_limit / block_factor as i64) != limit {
+ let c_str_limit = CString::new("limit").unwrap();
+ unsafe { sh_erange(cmdarg, c_str_limit.as_ptr() as *mut libc::c_char) };
+ return EXECUTION_FAILURE!();
+ }
+ } else {
+ sh_invalidnum(cmdarg);
+ return EXECUTION_FAILURE!();
+ }
+ if set_limit(limind, real_limit, mode) < 0 {
+ builtin_error(
+ b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char,
+ limits[limind as usize].description,
+ strerror(*__errno_location()) as *const libc::c_char,
+ );
+ return EXECUTION_FAILURE!();
}
return EXECUTION_SUCCESS!();
-
}
-fn get_limit (mut ind : i32, softlim : *mut RLIMTYPE, hardlim : *mut RLIMTYPE ) -> i32 {
- let mut value : RLIMTYPE = 0 ;
- let mut limit: rlimit = rlimit { rlim_cur: 1, rlim_max: 1 };
+fn get_limit(ind: i32, softlim: *mut RLIMTYPE, hardlim: *mut RLIMTYPE) -> i32 {
+ let mut value: RLIMTYPE = 0;
+ let mut limit: rlimit = rlimit {
+ rlim_cur: 1,
+ rlim_max: 1,
+ };
if limits[ind as usize].parameter >= 256 {
match limits[ind as usize].parameter {
RLIMIT_FILESIZE!() => {
- if filesize (((&mut value) as *mut i64) as *mut u64) < 0 {
+ if filesize(((&mut value) as *mut i64) as *mut u64) < 0 {
return -1;
}
}
RLIMIT_PIPESIZE!() => {
- if unsafe {
- pipesize (((&mut value) as *mut i64) as *mut u64)} < 0 {
- return -1;
- }
-
+ if unsafe { pipesize(((&mut value) as *mut i64) as *mut u64) } < 0 {
+ return -1;
+ }
}
RLIMIT_OPENFILES!() => {
- value = unsafe {getdtablesize()} as RLIMTYPE ;
-
+ value = unsafe { getdtablesize() } as RLIMTYPE;
}
RLIMIT_VIRTMEM!() => {
- return unsafe {getmaxvm(softlim, hardlim as *mut libc::c_char) };
+ return unsafe { getmaxvm(softlim, hardlim as *mut libc::c_char) };
}
RLIMIT_MAXUPROC!() => {
- if getmaxuprc ((value as usize) as *mut u64) < 0 {
+ if getmaxuprc((value as usize) as *mut u64) < 0 {
return -1;
}
-
- }
- _ => {
- unsafe {
- *__errno_location() = libc::EINVAL;
- }
}
+ _ => unsafe {
+ *__errno_location() = libc::EINVAL;
+ },
}
unsafe {
- *softlim = value;
+ *softlim = value;
*hardlim = value;
}
return 0;
- }
- else{
+ } else {
unsafe {
- let ii = getrlimit(limits[ind as u32 as usize ].parameter as __rlimit_resource_t,
- &mut limit);
- if ii < 0 {
- return -1;
- }
+ let ii = getrlimit(
+ limits[ind as u32 as usize].parameter as __rlimit_resource_t,
+ &mut limit,
+ );
+ if ii < 0 {
+ return -1;
+ }
}
unsafe {
- // limit.rlim_max as i64);
+ // limit.rlim_max as i64);
*softlim = limit.rlim_cur as i64;
*hardlim = limit.rlim_max as i64;
}
@@ -730,42 +737,50 @@ fn get_limit (mut ind : i32, softlim : *mut RLIMTYPE, hardlim : *mut RLIMTYPE )
}
}
-fn set_limit (ind : i32, newlim : RLIMTYPE, mode : i32) -> i32{
- let mut limit : rlimit = rlimit { rlim_cur: 0, rlim_max: 0 };
- let mut val : RLIMTYPE = 0;
-
+fn set_limit(ind: i32, newlim: RLIMTYPE, mode: i32) -> i32 {
+ let mut limit: rlimit = rlimit {
+ rlim_cur: 0,
+ rlim_max: 0,
+ };
+ let mut val: RLIMTYPE = 0;
+
if limits[ind as usize].parameter >= 256 {
match limits[ind as usize].parameter {
RLIMIT_FILESIZE!() => {
unsafe {
*__errno_location() = libc::EINVAL;
}
- return -1;
+ return -1;
}
- RLIMIT_OPENFILES!() | RLIMIT_PIPESIZE !() |
- RLIMIT_VIRTMEM!() | RLIMIT_MAXUPROC !() |
- _ => {
+ RLIMIT_OPENFILES!()
+ | RLIMIT_PIPESIZE!()
+ | RLIMIT_VIRTMEM!()
+ | RLIMIT_MAXUPROC!()
+ | _ => {
unsafe {
*__errno_location() = libc::EINVAL;
}
return -1;
}
}
- }
- else{
+ } else {
if unsafe {
- getrlimit (limits[ind as usize].parameter
- as __rlimit_resource_t,&mut limit )
- } < 0 {
- return -1;
+ getrlimit(
+ limits[ind as usize].parameter as __rlimit_resource_t,
+ &mut limit,
+ )
+ } < 0
+ {
+ return -1;
}
- let b = unsafe {current_user.euid }!= 0 && newlim == RLIM_INFINITY!()
- && (mode & LIMIT_HARD!()) == 0 && limit.rlim_cur <= limit.rlim_max;
+ let b = unsafe { current_user.euid } != 0
+ && newlim == RLIM_INFINITY!()
+ && (mode & LIMIT_HARD!()) == 0
+ && limit.rlim_cur <= limit.rlim_max;
if b {
- val = limit.rlim_max as i64;
- }
- else {
- val = newlim;
+ val = limit.rlim_max as i64;
+ } else {
+ val = newlim;
}
if mode & LIMIT_SOFT!() != 0 {
limit.rlim_cur = val as u64;
@@ -773,41 +788,52 @@ fn set_limit (ind : i32, newlim : RLIMTYPE, mode : i32) -> i32{
if mode & LIMIT_HARD!() != 0 {
limit.rlim_max = val as u64;
}
- return
- unsafe {setrlimit(limits[ind as usize].parameter as __rlimit_resource_t, &mut limit)};
- }
+ return unsafe {
+ setrlimit(
+ limits[ind as usize].parameter as __rlimit_resource_t,
+ &mut limit,
+ )
+ };
+ }
}
-unsafe fn getmaxvm(softlim : *mut RLIMTYPE , hardlim : *mut libc::c_char) -> i32 {
- let mut datalim : rlimit = rlimit { rlim_cur: 0, rlim_max: 0 };
- let mut stacklim : rlimit = rlimit { rlim_cur: 0, rlim_max: 0 };
-
+unsafe fn getmaxvm(softlim: *mut RLIMTYPE, hardlim: *mut libc::c_char) -> i32 {
+ let mut datalim: rlimit = rlimit {
+ rlim_cur: 0,
+ rlim_max: 0,
+ };
+ let mut stacklim: rlimit = rlimit {
+ rlim_cur: 0,
+ rlim_max: 0,
+ };
+
if getrlimit(RLIMIT_DATA, &mut datalim) < 0 {
return -1;
}
- if getrlimit (RLIMIT_STACK, &mut stacklim) < 0 {
+ if getrlimit(RLIMIT_STACK, &mut stacklim) < 0 {
return -1;
- }
- *softlim = (datalim.rlim_cur as i64 / 1024 as i64) + (stacklim.rlim_cur as i64/1024 as i64);
- *hardlim = ((datalim.rlim_max as i64) /1024 as i64) as libc::c_char + (stacklim.rlim_max as i64/1024 as i64) as libc::c_char;
+ }
+ *softlim = (datalim.rlim_cur as i64 / 1024 as i64) + (stacklim.rlim_cur as i64 / 1024 as i64);
+ *hardlim = ((datalim.rlim_max as i64) / 1024 as i64) as libc::c_char
+ + (stacklim.rlim_max as i64 / 1024 as i64) as libc::c_char;
return 0;
}
-
-fn filesize(mut valuep: *mut rlim_t) -> i32 {
+
+fn filesize(_valuep: *mut rlim_t) -> i32 {
unsafe {
*__errno_location() = libc::EINVAL;
}
return -1;
}
-unsafe fn pipesize(mut valuep: *mut rlim_t) -> i32 {
- *((valuep as usize) as *mut rlim_t) = PIPE_BUF!() as rlim_t;
- return 0 ;
+unsafe fn pipesize(valuep: *mut rlim_t) -> i32 {
+ *((valuep as usize) as *mut rlim_t) = PIPE_BUF!() as rlim_t;
+ return 0;
}
-fn getmaxuprc(mut valuep: *mut rlim_t) -> i32 {
+fn getmaxuprc(valuep: *mut rlim_t) -> i32 {
let mut maxchild: i64 = 0;
- maxchild = unsafe{getmaxchild()};
+ maxchild = unsafe { getmaxchild() };
if maxchild < 0 as i32 as libc::c_long {
unsafe {
*__errno_location() = libc::EINVAL;
@@ -816,85 +842,94 @@ fn getmaxuprc(mut valuep: *mut rlim_t) -> i32 {
} else {
unsafe {
*valuep = maxchild as rlim_t;
- }
- return 0 ;
+ }
+ return 0;
};
}
-fn print_all_limits (mut mode : i32) {
- let mut i : i32 ;
- let mut softlim : RLIMTYPE = 0;
- let mut hardlim : RLIMTYPE = 0;
-
- if mode == 0
- {
+fn print_all_limits(mut mode: i32) {
+ let mut i: i32;
+ let mut softlim: RLIMTYPE = 0;
+ let mut hardlim: RLIMTYPE = 0;
+
+ if mode == 0 {
mode = mode | LIMIT_SOFT!();
}
i = 0;
- while limits[i as usize].option >0 {
-
+ while limits[i as usize].option > 0 {
if get_limit(i, &mut softlim, &mut hardlim) == 0 {
if mode & LIMIT_SOFT!() != 0 {
- printone(i,softlim,1);
+ printone(i, softlim, 1);
+ } else {
+ printone(i, hardlim, 1);
}
- else {
- printone(i, hardlim,1);
+ } else if unsafe { *__errno_location() != libc::EINVAL } {
+ unsafe {
+ builtin_error(
+ b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char,
+ limits[i as usize].description,
+ strerror(*__errno_location()) as *const libc::c_char,
+ );
}
}
- else if unsafe {
- *__errno_location() != libc::EINVAL } {
- unsafe {
- builtin_error(b"%s: cannot get limit : %s\0" as *const u8 as *const libc::c_char, limits[i as usize].description,
- strerror(*__errno_location()) as *const libc::c_char);
- }
- }
- i = i+1;
+ i = i + 1;
}
}
-fn printone (limind : i32, curlim :RLIMTYPE , pdesc : i32){
- let mut unitstr :[ libc::c_char; 64] = [0 ; 64];
- let mut factor : i32 ;
+fn printone(limind: i32, curlim: RLIMTYPE, pdesc: i32) {
+ let mut unitstr: [libc::c_char; 64] = [0; 64];
+ let factor: i32;
factor = BLOCKSIZE!(limits[limind as usize].block_factor);
if pdesc > 0 {
- if !limits[limind as usize].units.is_null(){
+ if !limits[limind as usize].units.is_null() {
unsafe {
- sprintf (unitstr.as_mut_ptr(), b"(%s, -%c) \0" as *const u8 as *const libc::c_char,
- limits[limind as usize].units,
- limits[limind as usize].option);
+ sprintf(
+ unitstr.as_mut_ptr(),
+ b"(%s, -%c) \0" as *const u8 as *const libc::c_char,
+ limits[limind as usize].units,
+ limits[limind as usize].option,
+ );
}
-
- }
- else {
+ } else {
unsafe {
- sprintf (unitstr.as_mut_ptr(),b"(-%c) \0" as *const u8 as *const libc::c_char,
- limits[limind as usize].option);
+ sprintf(
+ unitstr.as_mut_ptr(),
+ b"(-%c) \0" as *const u8 as *const libc::c_char,
+ limits[limind as usize].option,
+ );
}
}
- print!("{:<20} {:>20}", unsafe {
- CStr::from_ptr(limits[limind as usize].description).to_str().unwrap()}
- , unsafe {CStr::from_ptr(unitstr.as_mut_ptr()).to_str().unwrap()});
+ print!(
+ "{:<20} {:>20}",
+ unsafe {
+ CStr::from_ptr(limits[limind as usize].description)
+ .to_str()
+ .unwrap()
+ },
+ unsafe { CStr::from_ptr(unitstr.as_mut_ptr()).to_str().unwrap() }
+ );
}
if curlim == RLIM_INFINITY!() {
let c_str_unlimited = b"unlimited" as *const u8 as *const libc::c_char;
- println!("{}",unsafe {CStr::from_ptr(c_str_unlimited).to_str().unwrap()});
- }
-
- else if curlim == RLIM_SAVED_MAX!() {
+ println!("{}", unsafe {
+ CStr::from_ptr(c_str_unlimited).to_str().unwrap()
+ });
+ } else if curlim == RLIM_SAVED_MAX!() {
//println!("hard");
let c_str_hard = b"hard" as *const u8 as *const libc::c_char;
- println!("{}",unsafe {CStr::from_ptr(c_str_hard).to_str().unwrap()});
- }
- else if curlim == RLIM_SAVED_CUR!() {
+ println!("{}", unsafe {
+ CStr::from_ptr(c_str_hard).to_str().unwrap()
+ });
+ } else if curlim == RLIM_SAVED_CUR!() {
//println!("soft");
let c_str_soft = b"soft" as *const u8 as *const libc::c_char;
- println!("{}",unsafe {CStr::from_ptr(c_str_soft).to_str().unwrap()});
- }
- else{
- print_rlimtype ((curlim / factor as i64) as u64 , 1);
+ println!("{}", unsafe {
+ CStr::from_ptr(c_str_soft).to_str().unwrap()
+ });
+ } else {
+ print_rlimtype((curlim / factor as i64) as u64, 1);
}
-
}
/* Set all limits to NEWLIM. NEWLIM currently must be RLIM_INFINITY, which
@@ -903,28 +938,25 @@ fn printone (limind : i32, curlim :RLIMTYPE , pdesc : i32){
were set successfully, and 1 if at least one limit could not be set.
To raise all soft limits to their corresponding hard limits, use
- ulimit -S -a unlimited
+ ulimit -S -a unlimited
To attempt to raise all hard limits to infinity (superuser-only), use
- ulimit -H -a unlimited
+ ulimit -H -a unlimited
To attempt to raise all soft and hard limits to infinity, use
- ulimit -a unlimited
+ ulimit -a unlimited
*/
-fn print_rlimtype(num : u64, nl : i32)
-{
- if nl > 0{
+fn print_rlimtype(num: u64, nl: i32) {
+ if nl > 0 {
println!("{num}");
- }
- else {
+ } else {
print!("{num}");
}
}
+fn set_all_limits(mut mode: i32, newlim: RLIMTYPE) -> i32 {
+ let mut i: i32;
+ let mut retval: i32 = 0;
-fn set_all_limits (mut mode : i32 , newlim : RLIMTYPE) -> i32 {
- let mut i : i32 ;
- let mut retval : i32 = 0;
-
if newlim != RLIM_INFINITY!() {
unsafe {
*__errno_location() = libc::EINVAL;
@@ -933,22 +965,23 @@ fn set_all_limits (mut mode : i32 , newlim : RLIMTYPE) -> i32 {
}
if mode == 0 {
- mode = LIMIT_SOFT!()|LIMIT_HARD!();
+ mode = LIMIT_SOFT!() | LIMIT_HARD!();
}
- retval = 0 ;
+ retval = 0;
i = 0;
while limits[i as usize].option > 0 {
- if set_limit (i, newlim, mode) < 0 {
+ if set_limit(i, newlim, mode) < 0 {
unsafe {
- builtin_error(b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char, limits[i as usize].description,
- strerror(*__errno_location()) as *const libc::c_char);
+ builtin_error(
+ b"%s: cannot modify limit : %s\0" as *const u8 as *const libc::c_char,
+ limits[i as usize].description,
+ strerror(*__errno_location()) as *const libc::c_char,
+ );
}
- retval = 1;
- i = i +1;
+ retval = 1;
+ i = i + 1;
}
}
- return retval;
+ return retval;
}
-
-
diff --git a/bash-5.1/builtins_rust/umask/src/lib.rs b/bash-5.1/builtins_rust/umask/src/lib.rs
index 2ca353dec5c0a9a0e977449d390f216fc0e8ce94..0c89bc9d6d72ed0912693b66ee59a523d7efe3b5 100644
--- a/bash-5.1/builtins_rust/umask/src/lib.rs
+++ b/bash-5.1/builtins_rust/umask/src/lib.rs
@@ -6,7 +6,7 @@ extern crate libc;
use libc::{c_char,c_int};
use std::ffi::{CString};
use rcommon::{r_read_octal};
-use rcommon::{WordList, WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN,r_builtin_usage};
+use rcommon::{WordList, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
use rhelp::r_builtin_help;
//结构体
diff --git a/bash-5.1/builtins_rust/wait/src/lib.rs b/bash-5.1/builtins_rust/wait/src/lib.rs
index 32b5eb80e0add5198237bceb24af2126781bee49..0147c813f5901f9944d3b3ad1acc9431a5ac11ed 100644
--- a/bash-5.1/builtins_rust/wait/src/lib.rs
+++ b/bash-5.1/builtins_rust/wait/src/lib.rs
@@ -26,13 +26,13 @@ extern "C" {
) -> ::std::os::raw::c_int;
}
-use libc::{c_ulong, c_char, intmax_t, c_short,c_int, c_long};
+use libc::{c_char, intmax_t, c_short,c_int, c_long};
use std::ffi::{CString,};
-use nix::sys::signal::{SigSet, Signal};
+use nix::sys::signal::{SigSet};
use rjobs::{PROCESS,COMMAND, BLOCK_CHILD, UNBLOCK_CHILD};
use rread::{SHELL_VAR, sh_var_value_func_t, sh_var_assign_func_t};
use rcommon::{r_builtin_unbind_variable,r_builtin_usage,r_get_job_spec,WordList};
-use rcommon::{ WordDesc, EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE, EX_NOTFOUND, EX_NOEXEC, SUBSHELL_PAREN};
+use rcommon::{ EX_USAGE, EXECUTION_SUCCESS, EXECUTION_FAILURE};
use rhelp::r_builtin_help;
// 结构体
@@ -454,7 +454,7 @@ extern "C" fn r_set_waitlist(list:*mut WordList) -> i32{
let mut set:SigSet = SigSet::empty();
let mut oset:SigSet = SigSet::empty();
let mut job:i32;
- let mut r:i32;
+ let mut _r:i32;
let mut njob:i32;
let mut pid:intmax_t=0;
let mut l:*mut WordList;
diff --git a/bash-5.1/config.h b/bash-5.1/config.h
deleted file mode 100644
index 4a614133bb49be9ec6c49a8b3909a160039d7e99..0000000000000000000000000000000000000000
--- a/bash-5.1/config.h
+++ /dev/null
@@ -1,1250 +0,0 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h -- Configuration file for bash. */
-
-/* Copyright (C) 1987-2009,2011-2012,2013-2019 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Bash is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash. If not, see .
-*/
-
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
-/* Template settings for autoconf */
-
-#define __EXTENSIONS__ 1
-#define _ALL_SOURCE 1
-#define _GNU_SOURCE 1
-/* #undef _POSIX_SOURCE */
-/* #undef _POSIX_1_SOURCE */
-#define _POSIX_PTHREAD_SEMANTICS 1
-#define _TANDEM_SOURCE 1
-/* #undef _MINIX */
-
-/* Configuration feature settings controllable by autoconf. */
-
-/* Define JOB_CONTROL if your operating system supports
- BSD-like job control. */
-#define JOB_CONTROL 1
-
-/* Define ALIAS if you want the alias features. */
-#define ALIAS 1
-
-/* Define PUSHD_AND_POPD if you want those commands to be compiled in.
- (Also the `dirs' commands.) */
-#define PUSHD_AND_POPD 1
-
-/* Define BRACE_EXPANSION if you want curly brace expansion a la Csh:
- foo{a,b} -> fooa foob. Even if this is compiled in (the default) you
- can turn it off at shell startup with `-nobraceexpansion', or during
- shell execution with `set +o braceexpand'. */
-#define BRACE_EXPANSION 1
-
-/* Define READLINE to get the nifty/glitzy editing features.
- This is on by default. You can turn it off interactively
- with the -nolineediting flag. */
-#define READLINE 1
-
-/* Define BANG_HISTORY if you want to have Csh style "!" history expansion.
- This is unrelated to READLINE. */
-#define BANG_HISTORY 1
-
-/* Define HISTORY if you want to have access to previously typed commands.
-
- If both HISTORY and READLINE are defined, you can get at the commands
- with line editing commands, and you can directly manipulate the history
- from the command line.
-
- If only HISTORY is defined, the `fc' and `history' builtins are
- available. */
-#define HISTORY 1
-
-/* Define this if you want completion that puts all alternatives into
- a brace expansion shell expression. */
-#if defined (BRACE_EXPANSION) && defined (READLINE)
-# define BRACE_COMPLETION
-#endif /* BRACE_EXPANSION */
-
-/* Define DEFAULT_ECHO_TO_XPG if you want the echo builtin to interpret
- the backslash-escape characters by default, like the XPG Single Unix
- Specification V2 for echo.
- This requires that V9_ECHO be defined. */
-/* #undef DEFAULT_ECHO_TO_XPG */
-
-/* Define HELP_BUILTIN if you want the `help' shell builtin and the long
- documentation strings compiled into the shell. */
-#define HELP_BUILTIN 1
-
-/* Define RESTRICTED_SHELL if you want the generated shell to have the
- ability to be a restricted one. The shell thus generated can become
- restricted by being run with the name "rbash", or by setting the -r
- flag. */
-#define RESTRICTED_SHELL 1
-
-/* Define DISABLED_BUILTINS if you want "builtin foo" to always run the
- shell builtin "foo", even if it has been disabled with "enable -n foo". */
-/* #undef DISABLED_BUILTINS */
-
-/* Define PROCESS_SUBSTITUTION if you want the K*rn shell-like process
- substitution features "<(file)". */
-/* Right now, you cannot do this on machines without fully operational
- FIFO support. This currently include NeXT and Alliant. */
-#define PROCESS_SUBSTITUTION 1
-
-/* Define PROMPT_STRING_DECODE if you want the backslash-escaped special
- characters in PS1 and PS2 expanded. Variable expansion will still be
- performed. */
-#define PROMPT_STRING_DECODE 1
-
-/* Define SELECT_COMMAND if you want the Korn-shell style `select' command:
- select word in word_list; do command_list; done */
-#define SELECT_COMMAND 1
-
-/* Define COMMAND_TIMING of you want the ksh-style `time' reserved word and
- the ability to time pipelines, functions, and builtins. */
-#define COMMAND_TIMING 1
-
-/* Define ARRAY_VARS if you want ksh-style one-dimensional array variables. */
-#define ARRAY_VARS 1
-
-/* Define DPAREN_ARITHMETIC if you want the ksh-style ((...)) arithmetic
- evaluation command. */
-#define DPAREN_ARITHMETIC 1
-
-/* Define EXTENDED_GLOB if you want the ksh-style [*+@?!](patlist) extended
- pattern matching. */
-#define EXTENDED_GLOB 1
-
-/* Define EXTGLOB_DEFAULT to the value you'd like the extglob shell option
- to have by default */
-#define EXTGLOB_DEFAULT 0
-
-/* Define COND_COMMAND if you want the ksh-style [[...]] conditional
- command. */
-#define COND_COMMAND 1
-
-/* Define COND_REGEXP if you want extended regular expression matching and the
- =~ binary operator in the [[...]] conditional command. */
-#define COND_REGEXP 1
-
-/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and
- the `coproc' reserved word */
-#define COPROCESS_SUPPORT 1
-
-/* Define ARITH_FOR_COMMAND if you want the ksh93-style
- for (( init; test; step )) do list; done
- arithmetic for command. */
-#define ARITH_FOR_COMMAND 1
-
-/* Define NETWORK_REDIRECTIONS if you want /dev/(tcp|udp)/host/port to open
- socket connections when used in redirections */
-#define NETWORK_REDIRECTIONS 1
-
-/* Define PROGRAMMABLE_COMPLETION for the programmable completion features
- and the complete builtin. */
-#define PROGRAMMABLE_COMPLETION 1
-
-/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
- characters, even if the OS supports them. */
-/* #undef NO_MULTIBYTE_SUPPORT */
-
-/* Define DEBUGGER if you want to compile in some features used only by the
- bash debugger. */
-#define DEBUGGER 1
-
-/* Define STRICT_POSIX if you want bash to be strictly posix.2 conformant by
- default (except for echo; that is controlled separately). */
-/* #undef STRICT_POSIX */
-
-/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble
- memory contents on malloc() and free(). */
-#define MEMSCRAMBLE 1
-
-/* Define for case-modifying variable attributes; variables modified on
- assignment */
-#define CASEMOD_ATTRS 1
-
-/* Define for case-modifying word expansions */
-#define CASEMOD_EXPANSIONS 1
-
-/* Define to make the `direxpand' shopt option enabled by default. */
-/* #undef DIRCOMPLETE_EXPAND_DEFAULT */
-
-/* Define to make the `globasciiranges' shopt option enabled by default. */
-#define GLOBASCII_DEFAULT 1
-
-/* Define to allow functions to be imported from the environment. */
-#define FUNCTION_IMPORT 1
-
-/* Define AFS if you are using Transarc's AFS. */
-/* #undef AFS */
-
-#define ENABLE_NLS 1
-
-/* End of configuration settings controllable by autoconf. */
-/* Other settable options appear in config-top.h. */
-
-#include "config-top.h"
-
-/* Beginning of autoconf additions. */
-
-/* Characteristics of the C compiler */
-/* #undef const */
-
-/* #undef inline */
-
-#define restrict __restrict
-
-/* #undef volatile */
-
-/* Define if cpp supports the ANSI-C stringizing `#' operator */
-#define HAVE_STRINGIZE 1
-
-/* Define if the compiler supports `long double' variables. */
-#define HAVE_LONG_DOUBLE 1
-
-#define PROTOTYPES 1
-#define __PROTOTYPES 1
-
-/* #undef __CHAR_UNSIGNED__ */
-
-/* Define if the compiler supports `long long' variables. */
-#define HAVE_LONG_LONG 1
-
-#define HAVE_UNSIGNED_LONG_LONG 1
-
-/* The number of bytes in a int. */
-#define SIZEOF_INT 4
-
-/* The number of bytes in a long. */
-#define SIZEOF_LONG 8
-
-/* The number of bytes in a pointer to char. */
-#define SIZEOF_CHAR_P 8
-
-/* The number of bytes in a double (hopefully 8). */
-#define SIZEOF_DOUBLE 8
-
-/* The number of bytes in an `intmax_t'. */
-#define SIZEOF_INTMAX_T 8
-
-/* The number of bytes in a `long long', if we have one. */
-#define SIZEOF_LONG_LONG 8
-
-/* The number of bytes in a `wchar_t', if supported */
-#define SIZEOF_WCHAR_T 4
-
-/* System paths */
-
-#define DEFAULT_MAIL_DIRECTORY "/var/mail"
-
-/* Characteristics of the system's header files and libraries that affect
- the compilation environment. */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define to use GNU libc extensions */
-#define _GNU_SOURCE 1
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Memory management functions. */
-
-/* Define if using the bash version of malloc in lib/malloc/malloc.c */
-#define USING_BASH_MALLOC 1
-
-/* #undef DISABLE_MALLOC_WRAPPERS */
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca, as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define if you have and it should be used (not on Ultrix). */
-#define HAVE_ALLOCA_H 1
-
-/* Define if major/minor/makedev is defined in