pax_global_header 0000666 0000000 0000000 00000000064 13547564172 0014530 g ustar 00root root 0000000 0000000 52 comment=42e726f8d004ec2220a291f5a54f000a0c471762
ast-2020.0.0/ 0000775 0000000 0000000 00000000000 13547564172 0012540 5 ustar 00root root 0000000 0000000 ast-2020.0.0/.clang-format 0000664 0000000 0000000 00000001134 13547564172 0015112 0 ustar 00root root 0000000 0000000 # Use the Google style with these modifications and a couple of others:
#
# 1) Lines can be up to 100 chars long rather than 80.
# 2) Use a four space indent rather than two spaces.
#
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
# The following directives override defaults established above.
# We don't want OCLint pragmas to be reformatted.
CommentPragmas: '^!OCLINT'
# Do not try to infer the most common alignment of `&` and `*` by analyzing the
# source file. Use right alignment; i.e., bind to the symbol not the type.
DerivePointerAlignment: false
PointerAlignment: Right
ast-2020.0.0/.clang-tidy 0000664 0000000 0000000 00000000135 13547564172 0014573 0 ustar 00root root 0000000 0000000 CheckOptions:
- key: readability-braces-around-statements.ShortStatementLines
value: 1
ast-2020.0.0/.copr/ 0000775 0000000 0000000 00000000000 13547564172 0013561 5 ustar 00root root 0000000 0000000 ast-2020.0.0/.copr/Makefile 0000664 0000000 0000000 00000000460 13547564172 0015221 0 ustar 00root root 0000000 0000000 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
srpm:
dnf -y install git-core sed
$(current_dir)/prep.sh
rpmbuild -bs -D "dist %{nil}" -D "_sourcedir packaging/fedora" -D "_srcrpmdir $(outdir)" --nodeps packaging/fedora/ksh.spec
ast-2020.0.0/.copr/prep.sh 0000775 0000000 0000000 00000002062 13547564172 0015066 0 ustar 00root root 0000000 0000000 #!/bin/sh -euf
set -x
# Copr sets clone depth to 500 to avoid cloning big repositories
# however we use number of commits in version number, so fetch
# full repository
# If `get fetch --unshallow` fails, this means if we have full
# repo, so ignore if it fails.
git fetch --unshallow || :
# Fetch tags to determine version number
git fetch --tags
# 2017.0.0-devel-1535-g7c33a1cd-dirty
VCS_VERSION=$(git describe --always --dirty --tags)
# Extract development version number i.e. 2017.0.0
DEVEL_VERSION_NUM=$(echo "$VCS_VERSION" | cut -d'-' -f1)
# 1535
COMMIT_NUM=$(echo "$VCS_VERSION" | cut -d'-' -f3)
# g7c33a1cd
SHORT_COMMIT=$(echo "$VCS_VERSION" | cut -d'-' -f4)
COMMIT=$(git rev-parse HEAD)
sed "s,#VCS_VERSION#,${VCS_VERSION},;
s,#DEVEL_VERSION_NUM#,${DEVEL_VERSION_NUM},;
s,#COMMIT_NUM#,${COMMIT_NUM},;
s,#SHORT_COMMIT#,${SHORT_COMMIT},;
s,#COMMIT#,${COMMIT}," \
packaging/fedora/ksh.spec.in > packaging/fedora/ksh.spec
git archive --prefix "ast-${COMMIT}/" --format "tar.gz" HEAD -o "packaging/fedora/ksh-${SHORT_COMMIT}.tar.gz"
ast-2020.0.0/.cppcheck.rules 0000664 0000000 0000000 00000001430 13547564172 0015450 0 ustar 00root root 0000000 0000000
wcwidth \(
wcwidthForbidden
warning
Always use fish_wcwidth rather than wcwidth.
wcswidth \(
wcswidthForbidden
warning
Always use fish_wcswidth rather than wcswidth.
<--!>
]]>
ast-2020.0.0/.cppcheck.suppressions 0000664 0000000 0000000 00000002700 13547564172 0017074 0 ustar 00root root 0000000 0000000 // suppress all instances of varFuncNullUB: "Passing NULL after the last typed
// argument to a variadic function leads to undefined behaviour." That's
// because all the places we do this are valid and won't cause problems even
// on a ILP64 platform because we're careful about using NULL rather than 0.
varFuncNullUB
// Suppress the warning about unmatched suppressions. At the moment these
// warnings are emitted even when removing the suppression comment results in
// the warning being suppressed. In other words this unmatchedSuppression
// warnings are false positives.
unmatchedSuppression
// There is currently one function which triggers this warning multiple times:
// src/cmd/ksh93/sh/io.c. Those warnings are all false positives. Suppressing
// them with inline warnings is too hideous to allow so globally suppress them.
resourceLeak
// For the moment we ignore warnings about using non-reentrant functions when
// a reentrant thread-safe variant exists. Since ksh is single-threaded this
// isn't a problem although it could be is a third-party plugin created
// threads that used any of these functions.
getpwuidCalled
ttynameCalled
getloginCalled
getpwnamCalled
// The fallbacks.c module is likely to need cppcheck suppressions. But due to
// how they are parsed, independent of any enclosing `#if` directives, they are
// also likely to cause warnings like "Unmatched suppression: mktempCalled".
unmatchedSuppression:../src/lib/libast/misc/fallbacks.c
ast-2020.0.0/.editorconfig 0000664 0000000 0000000 00000000317 13547564172 0015216 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_size = 4
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
[{Makefile,*.in}]
indent_style = tab
ast-2020.0.0/.github/ 0000775 0000000 0000000 00000000000 13547564172 0014100 5 ustar 00root root 0000000 0000000 ast-2020.0.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 13547564172 0016263 5 ustar 00root root 0000000 0000000 ast-2020.0.0/.github/ISSUE_TEMPLATE/bug_report.md 0000664 0000000 0000000 00000000350 13547564172 0020753 0 ustar 00root root 0000000 0000000 ---
name: Bug report
about: Template for bug reports
---
**Description of problem:**
**Ksh version:**
**How reproducible:**
**Steps to reproduce:**
1.
2.
3.
**Actual results:**
**Expected results:**
**Additional info:**
ast-2020.0.0/.gitignore 0000664 0000000 0000000 00000001157 13547564172 0014534 0 ustar 00root root 0000000 0000000 # There are some patterns below we include reluctantly. They should be in an
# individual's ~/.config/git/ignore file. For example, ".DS_Store" for people
# working on MacOS. We include them to help ensure they don't added to the
# project.
# Files and file extensions that should never be checked in regardless of
# which project directory they reside in.
*.exe
*.app
*.so
*.dylib
*.dll
*.lai
*.la
*.a
*.lib
*.o
*.obj
*.lo
*.slo
*.d
*.gch
*.pch
*.bak
*.new
*.orig
*.log
*.DS_Store
*~
*~HEAD
.AppleDouble
.LSOverride
.Trash-*
._*
Desktop.ini
# Artifacts of the build and test process that should not be committed.
build/
ast-2020.0.0/.oclint 0000664 0000000 0000000 00000012667 13547564172 0014045 0 ustar 00root root 0000000 0000000 rules:
rule-configurations:
# This is the default value (as of the time I wrote this) but I'm making
# it explicit since it needs to agree with the value used by clang-format.
# Thus, if we ever change the style guide to allow longer or shorter lines
# this should be changed (as well as the corresponding .clang-format file).
- key: LONG_LINE
value: 100
# The default limit for the length of variable names is 20. Long names are
# problematic but twenty chars results in way too many errors. So increase
# the limit to something more reasonable.
- key: LONG_VARIABLE_NAME
value: 30
# TODO: Return this to a saner value such as 60 (or even 100) once the
# truly obscene functions have been refactored.
#
# We're slightly more persmissive regarding the total number of lines in a
# function. Default is 50.
- key: LONG_METHOD
value: 500
# TODO: Return this to the default of 5 once the more egregious nested
# blocks have been eliminated.
#
# We're slightly more persmissive regarding the nested block depth.
# Default is 5.
- key: NESTED_BLOCK_DEPTH
value: 7
# We're slightly more persmissive regarding the number of non-comment
# lines in a function. Default is 30.
- key: NCSS_METHOD
value: 40
# We're willing to allow slighly more linearly independent paths through a
# function. Most of our code has a lot of `switch` blocks or consecutive
# `if` tests that are straightforward to interpret but which increase this
# metric. Default is 10.
- key: CYCLOMATIC_COMPLEXITY
value: 14
# We're willing to allow slighly more execution paths through a function.
# Default is 200.
- key: NPATH_COMPLEXITY
value: 300
disable-rules:
#
# A few instances of "useless parentheses" errors are meaningful. Mostly
# in the context of the `return` statement. Unfortunately the vast
# majority would result in removing parentheses that decreases
# readability. So we're going to ignore this warning and rely on humans to
# notice when the parentheses are truly not needed.
#
# Also, some macro expansions, such as FD_SET(), trigger this warning and
# we don't want to suppress each of those individually.
#
- UselessParentheses
#
# OCLint wants variable names to be at least three characters in length.
# Which would be fine if it supported a reasonable set of exceptions
# (e.g., "i", "j", "k") and allowed adding additional exceptions to match
# conventions employed by a project. Since it doesn't, and thus generates
# a lot of really annoying warnings, we're going to disable this rule.
#
- ShortVariableName
#
# This rule flags perfectly reasonable conditions like `if (!some_condition)`
# and is therefore just noise. Disable this rule.
#
- InvertedLogic
#
# The idea behind the "double negative" rule is sound since constructs
# like "!!(var & flag)" should be written as "static_cast(var &
# flag)". Unfortunately this rule has way too many false positives;
# especially in the context of assert statements. So disable this rule.
#
- DoubleNegative
#
# Avoiding bitwise operators in a conditional is a good idea with one
# exception: testing whether a bit flag is set. Which happens to be the
# only time you'll see something like `if (j->flags & JOB_CONSTRUCTED)`
# in project source.
#
- BitwiseOperatorInConditional
#
# I don't think I've ever seen a case where assigning a value to a
# parameter inside the function body was unclear, let along dangerour or
# an error. This rule is therefore just noise. Disable this rule.
#
- ParameterReassignment
#
# The project makes so much use of the `goto` statement, many of which
# will require significant refactoring to remove, that warnings about its
# use are just noise.
#
- GotoStatement
#
# Oclint has too many false positives regarding missing `break;`
# statements. Mostly having to do with `case` blocks that use `goto` to
# exit the block. In some cases because it doesn't recognize
# `__builtin_unreachable()` to flag that the previous statement won't
# return. And the compiler already alerts us to case blocks that fall
# through to the next case block.
- MissingBreakInSwitchStatement
#
# This warning is perfectly reasonable for most projects but not for ksh.
# There are simply too many `switch` blocks with as little as two branches
# but which we cannot justify rewriting.
# TODO: Enable this warning in the future.
#
- TooFewBranchesInSwitchStatement
#
# The structure of the code means that it is often clearer to nest `if()`
# statements even though they could be written as a single `if()`. I've
# simplified all the instances where no clarity is lost by combining them.
# Those instances that remain would be made harder to read and reason
# about if they were combined. Eliminating these instances requires
# refactoring that is hard to justify. So disable this warning.
- CollapsibleIfStatements
#
# TODO: Enable These in the future after simpler or more serious issues
# have been addressed. At this time these warnings just make it hard to
# see the issues that are easier or more urgent to resolve. So disable them.
#
- HighCyclomaticComplexity
- HighNPathComplexity
- HighNcssMethod
ast-2020.0.0/.travis.yml 0000664 0000000 0000000 00000007665 13547564172 0014667 0 ustar 00root root 0000000 0000000 sudo: required
language: c
# Get full repo to correctly determine tags from commits
git:
depth: false
# Use docker to test builds on different Linux distros.
# Latest stable image of each distro is pulled to test builds.
matrix:
include:
# https://hub.docker.com/_/fedora/
- os: linux
compiler: gcc
env:
- DISTRO_TYPE=fedora
INSTALL_REQUIREMENTS="dnf repolist; dnf --allowerasing install -y gcc python3 meson sudo langpacks-zh_CN ed ncurses vi findutils which nmap-ncat expect git glibc-all-langpacks procps"
before_install:
- docker pull ${DISTRO_TYPE}
# https://hub.docker.com/_/opensuse/
# Note: Meson 0.44.0 is the newest version that works with Python
# 3.4 available on OpenSuse Leap. See issue #430.
- os: linux
compiler: gcc
env:
- DISTRO_TYPE=opensuse/tumbleweed
INSTALL_REQUIREMENTS="zypper refresh; zypper in -y gcc python3 python3-pip ninja sudo glibc-locale glibc-devel ed ncurses-utils vim findutils which netcat expect git; pip3 install meson==0.44.0"
before_install:
- docker pull ${DISTRO_TYPE}
# https://hub.docker.com/_/ubuntu/
# Ubuntu requires explicitly generating en_US.UTF-8 locale
- os: linux
compiler: gcc
env:
- DISTRO_TYPE=ubuntu
INSTALL_REQUIREMENTS="apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install -yq gcc python3 sudo locales ed vim python3-pip ninja-build findutils debianutils netcat-openbsd expect git procps; pip3 install meson==0.44.0; locale-gen en_US.UTF-8"
before_install:
- docker pull ${DISTRO_TYPE}
# https://hub.docker.com/_/debian/
# Debian requires explicitly generating en_US.UTF-8 locale too
- os: linux
compiler: gcc
env:
- DISTRO_TYPE=debian
INSTALL_REQUIREMENTS="apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install -yq gcc python3 python3-pip ninja-build sudo locales ed vim procps findutils debianutils netcat-openbsd expect git; pip3 install meson==0.44.0; sed -i '/# en_US.UTF-8 UTF-8/s/..//' /etc/locale.gen && locale-gen"
before_install:
- docker pull ${DISTRO_TYPE}
# https://hub.docker.com/r/i386/ubuntu/
# 32-bit environment
# i686 images are built officially by docker but not supported
# https://github.com/docker-library/official-images#architectures-other-than-amd64
- os: linux
compiler: gcc
env:
- DISTRO_TYPE=i386/ubuntu
INSTALL_REQUIREMENTS="apt-get update; DEBIAN_FRONTEND=noninteractive apt-get install -yq gcc python3 sudo locales ed vim python3-pip ninja-build findutils debianutils netcat-openbsd expect git; pip3 install meson==0.44.0; locale-gen en_US.UTF-8"
before_install:
- docker pull ${DISTRO_TYPE}
- os: osx
compiler: clang
before_install:
- brew update
env:
# This variable is not required by macOS builds, but setting it for Travis dashboard.
- DISTRO_TYPE=macOS
- os: linux
env:
- SCAN_TYPE="shellcheck"
before_install:
- sudo apt-get update
- sudo apt-get install shellcheck findutils file
services:
- docker
script:
# Fetch tags to set version number
- git fetch --tags
- if [[ $SCAN_TYPE == "shellcheck" ]]; then exec bin/shellcheck; fi
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then exec scripts/build-on-macos.sh; fi
- docker run -v $TRAVIS_BUILD_DIR:/source ${DISTRO_TYPE} bash -c "set -e;
${INSTALL_REQUIREMENTS};
useradd --create-home test;
echo \"/tmp/ksh_auditfile;\$(id -u test)\" > /etc/ksh_audit;
chown -R test /source;
sudo -u test /source/scripts/build-on-docker.sh '${DISTRO_TYPE}'"
ast-2020.0.0/CHANGELOG.md 0000664 0000000 0000000 00000033624 13547564172 0014361 0 ustar 00root root 0000000 0000000 # ksh 2020.0.0
This documents changes since the AST code, which includes the `ksh` program,
was moved to Github. That is, the ksh93u+ source. The next stable version will
be treated as a major release for several reasons. Not least of which is
changing the build tool chain from the legacy Nmake system to Meson and
replacing the AST Vmalloc subsystem with the platform Malloc subsystem. Legacy
changes can be found in the various `RELEASE` files.
Starting in June 2017 maintenance of the Korn shell (`ksh`) resumed with
the merging of some fixes from Red Hat by Siteshwar Vashisht after he was
granted commit privilege. In October 2017 Kurtis Rader noticed that `ksh`
had been open sourced and started contributing changes. This document
was subsequently created to document the work being done.
## Deprecations
- Some libc/libm math functions not suitable for use by a ksh script (e.g.,
`j0()`) will likely be removed in the near future (issue #1346 and #88).
## Notable non-backward compatible changes
- The nonportable, unusable, `fpclassify` math function has been removed
(issue #1346).
- The broken math functions `nextforward` and `nexttoward` have been removed
(issue #1346).
- Support for binary plugins written for ksh93u+ or earlier releases has been
dropped (issue #983).
- Support for coshell has been removed (issue #619).
- The `universe` command has been removed (issue #793).
- The `getconf` command has been removed (issue #1118).
- Support for building on systems using EBCDIC has been removed (issue #742).
- Support for the `LC_OPTIONS` env var has been removed (issue #579).
- `case "[0-9]" in [0-9]) echo match;; esac` has stopped matching. When a case
statement doesn't match a pattern, it no longer tries to use the pattern as
a literal string (issue #476).
- echo builtin now interprets escape sequences and parses command line options
on all platforms. (issue #370)
- Support for the UWIN environment has been removed (issue #284).
- The experimental `SHOPT_FIXEDARRAY` feature has been removed. It is known to
have been enabled in some Fedora and RHEL builds. But because it was
experimental and undocumented this should not break any existing users of
`ksh` built with this feature enabled. (issue #234)
- <> operator now redirects standard input by default (issue #75).
- Support for the build time SHOPT_ACCTFILE symbol and code has been removed
(issue #210).
- Versioning scheme has been changed to use semantic version numbers (issue #335).
- Undocumented and broken `alarm` builtin has been removed (issue #646).
## Notable fixes and improvements
- `declare` has been added as an alias for `typeset` (issue #220).
- `local` has been added as a constrained alias for `typeset` when used inside
a function (issue #220).
- Mention of the `getconf` builtin has been removed from the main ksh man
page. That command has never been enabled by default and is now deprecated
in favor of the platform command of the same name (issue #1118).
- The `test` command no longer silently fails all uses of the `=~` operator.
Instead an error is printed suggesting the use of `[[...]]` (issue #1152).
- Doing `[ -t1 ]` inside a command substitution behaves correctly
(issue #1079).
- The project now passes its unit tests when built with malloc debugging
enabled (i.e., `meson test --setup=malloc`) or with ASAN enabled.
- Changes to the project are now validated by running unit tests on the Travis
continuous integration system.
- The ksh source now builds on BSD based systems such as macOS and FreeBSD.
- The ksh source now builds on Cygwin; albeit with many unit test failures.
- The legacy Nmake build system has been replaced by Meson. This improves the
build time by roughly an order of magnitude (issue #42).
- The `times` command is now a builtin that conforms to POSIX rather than an
alias for the `time` command (issue #16).
- The `time` command now has millisecond resolution if the platform provides
`getrusage()` and its time values have millisecond or better resolution.
## Other significant changes
- Using a bare tilde (e.g., `cd ~`) now works correctly if `$HOME` is not set
(issue #1391).
- You can no longer run an external command with stdin, stdout, or stderr
closed. If you attempt to do so (e.g., `a_cmd <&-`) it will be opened on
/dev/null in the child process (issue #1117).
- Vi raw mode is now the default and cannot be disabled. Note that this was
true at least as far back as ksh93u+. The difference is that now it's no
longer even theoretically possible to even build with that feature disabled.
(issue #864).
- The AST locale subsystem has been replaced by the platform's implementation
(issue #579).
- The AST Vmalloc subsystem has been removed. The project now uses the system
malloc. (issue #396)
- Operations that depend on the simulated 3DFS behavior found in release
ksh93v are no longer supported. That behavior does not work in ksh93u (the
most recent stable release found in all distros) unless the 3D file system
is actually present. This includes operations such as this:
`exec {fd}
- 13-05-01 +Increased to maximum number of enumeration elements from 32K to
2G.
- 13-04-25 +The -K option has been added to set to sort indexed arrays of
compound elements based on a list of keys.
- 13-04-18 Added serialization to processing of CHLD traps.
- 13-04-15 ksh now waits for background jobs started in functions contained
in command substitution.
- 13-04-08 +ksh now sets .sh.sig.pid and .sh.sig.status for CHLD traps. The
.sh.sig.status can be one of exited, killed, dumped, stopped or
continued.
- 13-04-08 +The CHLD trap is now triggered with STOP and CONT signals.
- 13-04-03 +Functions that are used in brace group command substitution ${ ... }
can assign the result to .sh.value instead of writing to standard
out with the same result, but faster.
- 13-03-27 +The variable .sh.sig containing siginfo information is no set during
a SIGCHLD trap.
- 13-03-12 Empty fields and empty arrays as type elements are not displayed
when expanding a type instance.
- 13-03-11 The trap command now blocks signals that have traps until the
trap command completes.
- 13-03-11 Signals that have traps that occur while processing a trap are
deferred until the trap command completes.
- 13-02-08 +The -p option was added to enum to display the values that are
valid for the enum.
- 13-02-07 +A preset alias named bool which is an alias for an enum
named `_Bool` which has values true and false has been added.
- 13-02-24 Increased the maximum level of recursion for evaluating variables
inside arithmetic expressions from 9 to 1024.
- 13-01-17 +User define math functions introduced on 10-03-24 now allow passing
arrays as arguments.
- 13-01-10 +ksh now treats ESC-O-letter the same as ESC-[-letter in vi and emacs
edit modes.
- 12-10-09 +read -d '' now reads up to a NUL byte.
- 12-10-04 libcmd builtins are statically linked into ksh93 and by default are
bound to the path /opt/ast/bin whether this path exists or not.
Changing the .sh.op_astbin variable changes the binding.
- 12-10-01 +Added the variable `SH_OPTIONS` which consists of name=value pairs.
For defined options it assigned value to the variable .sh.op_name.
- 12-10-02 +Add the variable .sh.op_astbin to define the directory where several
shell builtins will be bound.
- 12-09-10 +Added ~{fd} expansion where fd is the number of an open file or
a variable whose value is the number of an open file.
- 12-08-30 For an associative array A, $((A[sub])) no longer cause subscript sub
to be created.
- 12-08-20 typeset -H foo no longer un-sets foo when foo has been exported to
the shell.
- 12-07-12 +Added -q option was added to kill to send queued signals on systems
that support sigqueue().
- 12-07-12 +Added -p option to builtin to output builtins in a format that can
be used to re-input.
- 12-07-02 +The -a option was added to trap to cause the current setting to be
appended to the new trap setting rather than replacing it.
ast-2020.0.0/CONTRIBUTING.md 0000664 0000000 0000000 00000035666 13547564172 0015011 0 ustar 00root root 0000000 0000000 # Guidelines for Developers
This document provides guidelines for making changes to the AST Korn shell
project. This includes assumptions you can make about environments where
this project will be built. As well as rules for how to format the code,
naming conventions, etcetera. Generally known as the style of the code. It
also includes recommended best practices such as creating a Travis-CI
account so you can verify your changes pass all the tests before making
a pull-request.
See the bottom of this document for help on installing the linting and
style reformatting tools discussed in the following sections.
AST Korn shell source requires, and should limit the features it uses,
to a C compiler that provides those features available in C99 (aka ISO/IEC
9899:1999). See [issue #145](https://github.com/att/ast/issues/145).
When introducing a new dependency please make it optional with graceful
failure if possible. Add any new dependencies to the README.md document under
the *Running* and/or *Building* sections as well as in this document as
appropriate.
## Assumptions about what can be used
Do not use anything other than */bin/sh* to run scripts executed by Meson's
`run_command()` function. That is, any script run that way should begin
with `#!/bin/sh`. Furthermore, do not assume that path is a synonym for
`bash`. All scripts run during the Meson configuration and build steps
should only use features known to be available in the Bourne shell. This
makes it easier to bootstrap building `ksh` on systems, like OpenBSD,
which do not install bash by default.
## Versioning
We have switched to [semantic versioning](https://semver.org/)(issue #335).
To maintain backward compatibility we will use year as major version number,
so the scheme looks like yyyy.minor.patch. For e.g. 2017.0.0.
## Include What You Use
You should not depend on symbols being visible to a `*.c` module from
`#include` statements inside another header file. In other words if your
module does `#include "defs.h"` and that header does `#include "name.h"`
your module should not assume the sub-include is present. It should instead
directly `#include "name.h"` if it needs any symbol from that header. That
makes the actual dependencies much clearer. It also makes it easy to modify
the headers included by a specific header file without having to worry
that will break any module (or header) that includes a particular header.
To help enforce this rule the `bin/lint` command will run the
[include-what-you-use](http://include-what-you-use.org/)
tool. You can find the IWYU project on
[github](https://github.com/include-what-you-use/include-what-you-use).
To install the tool on macOS you'll need to add a
[formula](https://github.com/jasonmp85/homebrew-iwyu) then install it:
```sh
brew tap jasonmp85/iwyu
brew install iwyu
```
On Ubuntu you can install it via `sudo apt-get install iwyu`.
## Lint Free Code
Automated analysis tools like `cppcheck` and `oclint` can point out potential
bugs or code that is extremely hard to understand. They also help ensure
the code has a consistent style and that it avoids patterns that tend to
confuse people.
Ultimately we want lint free code. This includes no compiler warnings and
no warnings from the aforementioned tools. However, at the moment a lot
of cleanup is required to reach that goal. For now simply try to avoid
introducing new lint.
To make linting the code easy there is the `bin/lint` command. If you
pass it the magic string `--all` it will lint all the *src/cmd/ksh93*
code. If you pass it a list of files it will lint those. The paths can be
directory names in which case all the source beneath that directory will
be linted. If run with no arguments it will lint any uncommitted source
files. If there are no uncommitted files it will lint the files in the
most recent commit.
### Dealing With Lint Warnings
You are strongly encouraged to address a lint warning by refactoring
the code, changing variable names, adding an explicit initialization,
or whatever action is implied by the warning.
### Suppressing Lint Warnings
Once in a while the lint tools emit a false positive warning. For example,
`cppcheck` might suggest a memory leak is present when that is not the
case. To suppress that `cppcheck` warning you should insert a line like
the following immediately prior to the line `cppcheck` warned about:
```c
// cppcheck-suppress memleak // addr not really leaked
```
Suppressing `oclint` warnings is more complicated
to describe so I'll refer you to the
[OCLint HowTo](http://docs.oclint.org/en/latest/howto/suppress.html#annotations)
on the topic.
## Ensuring Your Changes Conform to the Style Guides
The following sections discuss the specific rules for the style that
should be used when writing AST ksh code.
To make restyling the code easy there is the `bin/style` command. If you
pass it the magic string `--all` it will restyle all the *src/cmd/ksh93*
code. If you pass it a list of files it will restyle those. The paths can be
directory names in which case all the source beneath that directory will
be restyled. If run with no arguments it will restyle any uncommitted source
files. If there are no uncommitted files it will restyle the files in the
most recent commit.
To ensure your changes conform to the style rules you simply need to run
```sh
bin/style
```
before committing your change. That will run `git-clang-format` to rewrite
just the lines you're modifying.
If you've already committed your changes that's okay since it will then
check the files in the most recent commit. This can be useful after
you've merged someone elses change and want to check that it's style
is correct. However, in that case it will run `clang-format` to ensure
the entire file, not just the lines modified by the commit, conform to
the style.
### Configuring Your Editor
#### ViM
If you use ViM I recommend the [vim-clang-format plugin](https://github.com/rhysd/vim-clang-format) by [@rhysd](https://github.com/rhysd).
You can also get ViM to provide reasonably correct behavior by installing
http://www.vim.org/scripts/script.php?script_id=2636
#### Emacs
If you use Emacs: TBD
### Configuring Your Editor for Ksh Scripts
TBD
### Suppressing Reformatting of C Code
If you have a good reason for doing so you can tell `clang-format` to
not reformat a block of code by enclosing it in comments like this:
```c
// clang-format off
code to ignore
// clang-format on
```
However, as I write this there are no places in the code where we use
this and I can't think of any legitimate reasons for exempting blocks of
code from clang-format.
## Ksh Script Style Guide
TBD
## C Style Guide
Note: While `clang-format` is authoritative with respect to everything it
handles (e.g., indentation, spacing around operators) there are some things it
won't fix. So please read the following items.
1. The [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
forms the basis of this projects C style guide. There are two major
deviations for this project. First, a four, rather than two, space
indent. Second, line lengths up to 100, rather than 80, characters. See
[issue #125](https://github.com/att/ast/issues/125).
1. The `clang-format` command is authoritative with respect to indentation,
whitespace around operators, line breaks, etc.
1. All names in code should be `small_snake_case`. No Hungarian notation is used.
1. Always attach braces to the surrounding context.
1. Indent with spaces, not tabs and use four spaces per indent.
1. Comments should always use the C++ style; i.e., each line of the
comment should begin with a `//` and should be limited to 100 characters.
1. Comments that appear on the same line as a statement should be separated
from the previous text by two spaces. The comment should not be in the
form of a sentence; i.e., `// allow room to prepend args` not `// Allow
room to prepend args.`. If the comment is on its own line(s) it should
be written as a sequence of sentences like you would in any document.
1. All switch `case` blocks should be enclosed in braces. For example:
```c
switch (x) {
case 1: {
do_something();
break;
}
case 2: {
do_something_else();
break;
}
}
```
1. If a switch `case` block is meant to fall-through to the following
block add an explicit comment: `// FALL THRU`.
1. If a `if` statement has a corresponding `else if` or `else` block you
must put the blocks on separate lines enclosed in braces even if they
would otherwise fit on the preceding control statement. For example:
```c
if (a) {
do_a();
} else {
abort();
}
```
1. A `if` or `while` statement whose block is a single line can put the
two statements on the same line if there is room. In that case omit the
braces. Otherwise, even if the block is a single line it must be enclosed
in braces. For example:
```c
if (a || b) do_something();
if (some_really_long_complex_condition_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) {
do_something();
}
```
Never do this even though the C language allows it since it is an
anti-pattern that leads to bugs:
```c
if (some_really_long_complex_condition_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
do_something();
if (is_true()) {
do_x();
do_y();
} else
do_z();
```
## Testing
The source code for ksh includes a large collection of tests. If you
are making any changes to ksh, running these tests is mandatory to
make sure the behavior remains consistent and regressions are not
introduced. Even if you don't run the tests they will be run via the
[Travis CI](https://travis-ci.org/att/ast) service.
You are strongly encouraged to add tests when changing the functionality
of ksh. Especially if you are fixing a bug to help ensure there are no
regressions in the future (i.e., we don't reintroduce the bug).
### Local testing
The tests can be run on your local computer on all operating systems supported
by the project. To run the tests:
```
cd build
meson test --setup=malloc
```
To run a specific test include its name: `meson test --setup=malloc types`.
The `--setup=malloc` will enable malloc integrity features provided by your
system's malloc implementation if it supports such things via environment
variables. That flag can be omitted but its use is recommended.
### Testing with ASAN -- AddressSanitizer
At the moment this only works on Linux using gcc.
Configure with `meson -DASAN=true -Dbuild-api-tests=false`. Then build with
`ninja` as usual. Run the tests with `meson test --setup=asan`.
You will need to install the `llvm-symbolizer` tool if the gcc version is less
than 4.9.3. For example, on OpenSuse 42.3 you'll need to run `sudo zypper
install llvm`.
### Testing with Valgrind
The `valgrind` tool is invaluable for finding bugs that may only manifest in
specific situations due to the vagaries of memory management and the placement
of variables, structures, etc. To run the tests under control of `valgrind` do
this:
```sh
meson test -t 10 --wrapper valgrind
```
The `-t 10` is a multiplier for test timeouts. A much larger multiplier,
on the order of `-t 50`, might be needed if you're running the tests in
a virtual machine or other environment with highly constrained resources.
### Travis CI Build and Test
The Travis Continuous Integration services can be used to test your
changes using multiple configurations. This is the same service that the
AST src/cmd/ksh93/data/bash\_pre\_rc.c shell project uses to ensure new
changes haven't broken anything. Thus it is a really good idea that you
leverage Travis CI before making a pull-request to avoid embarrassment at
breaking the build.
You will need to [fork the repository on GitHub](https://help.github.com/articles/fork-a-repo/).
Then setup Travis to test your changes before you make a pull-request:
1. [Sign in to Travis CI](https://travis-ci.org/auth) with your GitHub
account, accepting the GitHub access permissions confirmation.
1. Once you're signed in, and your repositories are synchronized, go to your [profile page](https://travis-ci.org/profile) and enable the ast repository.
1. Push your changes to GitHub.
You'll receive an email when the tests are complete telling you whether or not any tests failed.
You'll find the configuration used to control Travis in the `.travis.yml` file.
### Git hooks
Since developers sometimes forget to run the tests, it can be helpful to
use git hooks (see `githooks`(5)) to automate it.
One possibility is a pre-push hook script like this one:
```sh
#!/bin/sh
#### A pre-push hook for the ast/ksh project
# This will run the tests when a push to master is detected, and will stop that if the tests fail
# Save this as .git/hooks/pre-push and make it executable
protected_branch='master'
# Git gives us lines like "refs/heads/frombranch SOMESHA1 refs/heads/tobranch SOMESHA1"
# We're only interested in the branches
while read from _ to _; do
if [ "x$to" = "xrefs/heads/$protected_branch" ]; then
isprotected=1
fi
done
if [ "x$isprotected" = x1 ]; then
echo "Running tests before push to master"
cd build
meson test
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Tests failed for a push to master, we can't let you do that" >&2
exit 1
fi
fi
exit 0
```
This will check if the push is to the master branch and, if it is,
will run `meson test` and only allow the push if that succeeds. In some
circumstances it might be advisable to circumvent it with `git push
--no-verify`, but usually that should not be necessary.
To install the hook, put it in *.git/hooks/pre-push* and make it
executable.
To fix code styling issues before making a commit, add this
script as a pre-commit hook; that is in an executable file named
*.git/hooks/pre-commit*:
```sh
#!/bin/sh
STAGE_STYLE_FIXUPS=1 bin/style
```
### Test Coverage
Test coverage report can be generated with these commands:
```
cd build
meson -Db_coverage=true
ninja
meson test -t 2
ninja coverage-html
```
### Coverity Scan
Coverity scans are run everyday on `master` branch. Latest results can be viewed [here](https://scan.coverity.com/projects/ksh).
## Installing the Required Tools
### Installing the Linting Tools
To install the lint checkers on macOS using HomeBrew:
```sh
brew tap oclint/formulae
brew install oclint
brew install cppcheck
```
To install the lint checkers on Linux distros that use Apt:
```sh
sudo apt-get install clang
sudo apt-get install oclint
sudo apt-get install cppcheck
```
### Installing the Reformatting Tools
To install the reformatting tool on macOS using HomeBrew:
```sh
brew install clang-format
```
To install the reformatting tool on Linux distros that use Apt:
```sh
apt-cache install clang-format
```
That will list the versions available. Pick the newest one available
(3.9 for Ubuntu 16.10 as I write this) and install it:
```sh
sudo apt-get install clang-format-3.9
sudo ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format
```
## Message Translations
TBD
ast-2020.0.0/LICENSE 0000664 0000000 0000000 00000025761 13547564172 0013560 0 ustar 00root root 0000000 0000000 Eclipse Public License - v 1.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1. DEFINITIONS
"Contribution" means:
a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
"Contributor" means any person or entity that distributes the Program.
"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
"Program" means the Contributions distributed in accordance with this Agreement.
"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
a) it complies with the terms and conditions of this Agreement; and
b) its license agreement:
i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
When the Program is made available in source code form:
a) it must be made available under this Agreement; and
b) a copy of this Agreement must be included with each copy of the Program.
Contributors may not remove or alter any copyright notices contained within the Program.
Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
ast-2020.0.0/README.md 0000664 0000000 0000000 00000014701 13547564172 0014022 0 ustar 00root root 0000000 0000000 # KSH93
This repository contains the AT&T Software Technology (AST) toolkit
from AT&T Research. As of November 2017 the development focus has
been shifted to the `ksh` (or `ksh93`) command and supporting code required
to build it.
The non-ksh code of the AST project is no longer being actively
maintained. If you are interested in the non-ksh code see below for
details on which branches contain the full AST code base.
The project only supports systems where the compiler and underlying
hardware is ASCII compatible. This includes Linux on IBM zSeries but not
z/OS. The nascent, incomplete, support for EBCDIC has been removed. See
[issue #742](https://github.com/att/ast/issues/742).
## Building Korn shell
Building ksh requires the [Meson](http://mesonbuild.com/) build system. To
build ksh execute these commands from the project root directory:
```
meson build
ninja -C build
```
You can add a `--prefix` flag followed by a path to the `meson build` command
to specify where the binaries and libraries are installed. The default is
*/usr/local*.
## Installing
The `ksh` executable, helper libraries and man page can be installed with:
```
ninja -C build install
```
## Getting KornShell
### Linux
Latest builds for Red Hat Enterprise Linux (CentOS) and Fedora can be found in
[Copr](https://copr.fedorainfracloud.org/coprs/g/ksh/latest/).
Latest builds for openSUSE and Ubuntu can be found in
[OBS](https://build.opensuse.org/project/show/shells:ksh:new:latest).
See [full list](https://github.com/att/ast/wiki/Packages-for-Linux) of distros
that ship packages for current development version.
### Windows
TBD
### macOS
TBD
## Contributing changes to the source code
See the
[contributing guidelines](https://github.com/att/ast/blob/master/CONTRIBUTING.md)
for information about code style, unit tests, and other topics of interest
to anyone who wants to modify the source.
## Guidelines for Packagers
See the guidelines for downstream package maintainers [here](https://github.com/att/ast/wiki/Guidelines-for-Packagers).
## Coverity Scan
Latest results of coverity scan can be viewed [here](https://scan.coverity.com/projects/ksh).
## Test Coverage
A code coverage report can be viewed
[here](http://situ.im/ast/coveragereport/) for GCC on Linux, and
[here](https://www.skepticism.us/ast/coveragereport/) for LLVM/clang on macOS.
## Working with the full AST source
Warning: Running test cases through the legacy test script may wipe out your home directory
([See #477](https://github.com/att/ast/issues/477)). This has been fixed in current
development version.
Full AST source code is available under the `2012-08-01-master` and
`2016-01-10-beta` branches (see below for more details). Bug fixes to
these branches are welcome but they are otherwise under low maintenance.
The full AST code includes many tools and libraries, like KSH, NMAKE, SFIO,
VMALLOC, VCODEX, etc. It also includes efficient replacements for a
lot of the POSIX tools. It was designed to be portable across many UNIX
systems and also works under UWIN on Microsoft Windows (see UWIN repo on
GitHub under att/uwin).
This software is used to build itself, using NMAKE.
After cloning this repo, cd to the top directory of it and run:
```
./bin/package make
```
__NOTE__: That build command only applies to the legacy branches that include
the entire AST source. It does not apply to the current `master` branch that
is focused solely on the `ksh` command and uses the Meson build system.
Almost all the tools in this package (including the bin/package script) are
self-documenting; run --man (or --html) for the man page for the tool.
(If you were used to the old AST packaging mechanism, on www.research.att.com,
this repo is equivalent to downloading the INIT and ast-open packages and
running: ./bin/package read on them).
## Branches
The `master` [branch](https://github.com/att/ast/commits/master) contains
the current development version of ksh93. It only contains source code
for ksh93 and the libraries required to build it.
The [2012-08-01-master branch](https://github.com/att/ast/commits/2012-08-01-master)
contains the last stable release of
full AST source code. It contains one cherry-picked
[change](https://github.com/att/ast/commit/e79c29295092fe2b2282d134e2b7cce32ec9dcac)
to allow building on Linux.
The [2016-01-10-beta branch](https://github.com/att/ast/commits/2016-01-10-beta) contains
the last beta release of full AST source code plus a number of patches
that were later added on top of it. Changes for the legacy AST project are
normally merged to this branch.
The [gh-pages branch](https://github.com/att/ast/commits/gh-pages)
will probably be removed. It contains files needed to generate the static
[AST project page](https://att.github.io/ast/) hosted by GitHub. See
https://help.github.com/articles/what-is-github-pages/ for more info.
## Licensing
This section needs more detail and clarity. The original `README` document
said the following:
> Each package is covered by one of the license files
>
> lib/package/LICENSES/
>
> where is the license type for the package. At the top
> of each license file is a URL; the license covers all software that
> refers to this URL. For details run
>
> bin/package license []
>
> Any archives, distributions or packages made from source or
> binaries covered by license(s) must contain the corresponding
> license file(s).
## Contact Us
The primary mechanism for interacting with this project is the [GitHub
project](https://github.com/att/ast/) by opening issues and pull-requests
and watching the project.
### IRC
Use `#ksh` channel on freenode to discuss about AT&T KornShell and related variants.
### Gitter
[ksh93/users](https://gitter.im/ksh93/users) is the Gitter chatroom for
AT&T KornShell users.
### Mailing lists
You can track announcements and ask question or
report problems at korn-shell@googlegroups.com or
https://groups.google.com/d/forum/korn-shell as an alternative to watching
this Github project.
Archives of the AST mailing lists (which is mostly about ksh) are available at:
https://marc.info/?l=ast-developers and https://marc.info/?l=ast-users.
__As of 2018-11-01 the AT&T hosted mailing lists no longer respond to
email.__ Note that the precise date the mailing lists stopped working
is unknown. That was simply the date it came to our attention. The last
known message to both mailing lists was sent on 2018-03-15. Ironically,
since you can't unsubscribe, they still send monthly reminders that you
are subscribed.
ast-2020.0.0/app-compat-travis.yml 0000664 0000000 0000000 00000002006 13547564172 0016630 0 ustar 00root root 0000000 0000000 # Test compatibility with applications written in ksh
sudo: required
services:
- docker
matrix:
include:
- os: linux
env:
- PROJECT_NAME=kshdb
GIT_URL="https://github.com/rocky/kshdb.git"
COMMANDS="git checkout att-ksh93v-testing; ksh ./autogen.sh; make test"
# These tests are run from yash fork that contains list of tests and a test runner script
- os: linux
env:
- PROJECT_NAME="posix-shell-tests"
GIT_URL="https://github.com/siteshwar/posix-shell-tests.git"
COMMANDS="git checkout ksh-tests; cd src; LANG=C ./run-ksh-tests.sh"
script:
- docker pull fedora
# Test builds from https://copr.fedorainfracloud.org/coprs/g/ksh/latest/
- docker run fedora bash -c "
dnf install -y 'dnf-command(copr)';
dnf copr enable -y @ksh/latest;
dnf install -y ksh git autoconf automake make findutils yash;
git clone $GIT_URL;
cd $PROJECT_NAME;
$COMMANDS"
ast-2020.0.0/bin/ 0000775 0000000 0000000 00000000000 13547564172 0013310 5 ustar 00root root 0000000 0000000 ast-2020.0.0/bin/README 0000664 0000000 0000000 00000000227 13547564172 0014171 0 ustar 00root root 0000000 0000000 This directory is for commands that people working on this project might run.
For example, to restyle the source code or run it through linting tools.
ast-2020.0.0/bin/lint 0000775 0000000 0000000 00000017747 13547564172 0014224 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ksh
#
# Usage: bin/lint [all | directory_or_filename...]
#
# Run the source through various lint detection tools. If invoked with `-all` then all the
# src/cmd/ksh93 source files will be linted. If invoked with one or more path names they
# will be linted. If the pathname is a directory all *.c files inside it will be linted.
# Otherwise any uncommitted source files are linted. If there is no uncommitted change
# then the files in the most recent commit are linted.
#
# shellcheck disable=SC2207
# Note: Disable SC2207 warning for the entire file since setting IFS to just
# newline makes it safe to handle file names with spaces.
IFS=$'\n'
typeset all=no
readonly cppchecks=warning,performance,portability,information,missingInclude
typeset enable_global_analysis=""
typeset lint_args=""
typeset -a c_files=()
typeset -a files=()
readonly os_name=$(uname -s)
readonly machine_type=$(uname -m)
if [[ ! -d build || ! -f build/compile_commands.json ]]
then
echo "You need to run \`meson\` to configure the build before we can lint the source." >&2
exit 1
fi
# Deal with any CLI flags.
while [[ "${#}" -ne 0 ]]
do
case "${1}" in
--all | all )
all=yes
enable_global_analysis='-enable-global-analysis'
;;
* )
break
;;
esac
shift
done
if [[ ${all} == yes && "${#}" -ne 0 ]]
then
echo "Unexpected arguments: '${1}'" >&2
exit 1
fi
# Figure out which files to lint.
if [[ ${all} == yes ]]
then
files=( $(find src -name "*.c") )
elif [[ "${#}" -ne 0 ]]
then
for next_file in "$@"
do
if [[ -f ${next_file} ]]
then
files+=( "${next_file}" )
elif [[ -d ${next_file} ]]
then
files+=( $(find "${next_file}" -name "*.c") )
fi
done
else
# We haven't been asked to lint all the source or specific files. If there are uncommitted
# changes lint those, else lint the files in the most recent commit. Select (cached files)
# (modified but not cached, and untracked files).
files=( $(git diff-index --cached HEAD --name-only) )
files+=( $(git ls-files --exclude-standard --others --modified) )
if [[ "${#files[@]}" -eq 0 ]]
then
# No pending changes so lint the files in the most recent commit.
files=( $(git diff-tree --no-commit-id --name-only -r HEAD) )
fi
fi
# Filter out non C source files.
for file in "${files[@]}"
do
case "${file}" in
*.c )
if [[ -f "${file}" ]]
then
c_files+=( "../${file}" )
fi
;;
esac
done
cd build || exit 1
# We need to limit the source modules to those for which we have build rules. We also need to
# produce a version of the compile_commands.json file that only contains the files to be linted.
# Finally, we need the `-D` and `-I` flags from the build rule for the IWYU and cppcheck programs.
readonly project_file="compile_commands_partial.json"
c_files=( $(../scripts/partition_compile_db compile_commands.json ${project_file} "${c_files[@]}") )
if [[ "${#c_files[@]}" -eq 0 ]]
then
echo >&2
echo 'WARNING: No C files to check' >&2
echo >&2
exit 1
fi
# On some platforms (e.g., macOS) oclint can't find the system headers. So ask the real compiler
# to tell us where they are and pass that information to oclint.
#
# Passing this path via the compiler `-isystem` flag also keeps oclint from complaining about
# problems with the system headers.
#
# We also need this value for cppcheck to find some system headers again, on platforms like macOS,
# where the system headers aren't found at /usr/include.
readonly system_hdrs="$(clang -H -E ../etc/hdrs.c 2>&1 |
sed -ne 's,^\. \(.*\)/.*$,\1,p' -e '1,$!t' -e 'q')"
# On macOS the system headers used by `clang` may not be rooted at /usr/include.
lint_args=( -I. -I"${system_hdrs}" )
# This is needed with clang on macOS. Without it `cppcheck` fails with
# `#error Unsupported architecture` from `#include `.
if [[ "${machine_type}" == "x86_64" ]]
then
lint_args+=( -D__x86_64__ -D__LP64__ )
fi
if command -v include-what-you-use > /dev/null
then
echo
echo ========================================
echo Running IWYU
echo ========================================
typeset mapping_file=""
case "${os_name}" in
Darwin | FreeBSD | OpenBSD )
mapping_file="../etc/iwyu.bsd.map"
;;
Linux | CYGWIN* )
mapping_file="../etc/iwyu.linux.map"
;;
esac
set +x
for c_file in "${c_files[@]}"
do
if [[ "${mapping_file}" != "" ]]
then
# shellcheck disable=SC2046
include-what-you-use -Xiwyu --transitive_includes_only \
-Xiwyu --mapping_file="${mapping_file}" \
--std=c99 -Wno-expansion-to-defined -Wno-nullability-completeness \
"${lint_args[@]}" $(../scripts/extract_flags "${project_file}" "${c_file}") \
"${c_file}" 2>&1 | sed \
-e 's,^(\.\./,(,' -e 's,^\.\./,,' \
-e '/^(.* has correct #includes/d'
else # hope for the best
# shellcheck disable=SC2046
include-what-you-use -Xiwyu --transitive_includes_only \
--std=c99 -Wno-expansion-to-defined -Wno-nullability-completeness \
"${lint_args[@]}" $(../scripts/extract_flags "${project_file}" "${c_file}") \
"${c_file}" 2>&1 | sed \
-e 's,^(\.\./,(,' -e 's,^\.\./,,' \
-e '/^(.* has correct #includes/d'
fi
done
set +x
fi
if command -v cppcheck > /dev/null
then
echo
echo ========================================
echo Running cppcheck
echo ========================================
# The stderr to stdout redirection is because cppcheck, incorrectly IMHO, writes its
# diagnostic messages to stderr. Anyone running this who wants to capture its output will
# expect those messages to be written to stdout.
readonly cn="$(tput sgr0 | sed -e 's/'$'\xf''$//')"
readonly cb="$(tput bold)"
readonly cu="$(tput smul)"
readonly cm="$(tput setaf 125)"
readonly cbrm="$(tput setaf 201)"
readonly template="[${cb}${cu}{file}${cn}${cb}:{line}${cn}] ${cbrm}{severity}${cm} ({id}):${cn}\\n {message}"
# It should be possible to use --project=$project_file but cppcheck 1.82 doesn't correctly
# extract the -D and -I flags. So we do it ourselves and pass the flags on the cppcheck
# command line.
for c_file in "${c_files[@]}"
do
flags=( $(../scripts/extract_flags ${project_file} "${c_file}") )
cppcheck "${lint_args[@]}" \
"${flags[@]}" -D_CPPCHECK \
-q --verbose --std=c99 --language=c \
--suppress=missingIncludeSystem --inline-suppr \
--enable="${cppchecks}" --rule-file=../.cppcheck.rules \
--template="${template}" \
--suppressions-list=../.cppcheck.suppressions "${c_file}" 2>&1 |
sed -e 's,^\[\([^.]*\)\.\./,[\1,'
done
fi
if command -v oclint > /dev/null
then
echo
echo ========================================
echo Running oclint
echo ========================================
# A copy of this config file has to be in the CWD (the Meson build dir).
if [[ -f ../.oclint ]]
then
cp ../.oclint .
fi
# Include `-D_FORTIFY_SOURCE=0` because we don't want constant expressions
# introduced by the use of macro implementations of functions like
# `snprintf()` to cause spurious warnings when security fortification is
# in effect. Since we're just doing static analysis the run-time checks
# introduced by the indirections the _FORTIFY_SOURCE mechanism introduces
# serve no purpose.
oclint -p "${PWD}" -enable-clang-static-analyzer ${enable_global_analysis} \
-extra-arg="-D_OCLINT_" \
-extra-arg="-D_FORTIFY_SOURCE=0" \
-extra-arg="-isystem" -extra-arg="${system_hdrs}" "${c_files[@]}" 2>&1 |
sed -e 's,^\.\./,,'
fi
ast-2020.0.0/bin/shellcheck 0000775 0000000 0000000 00000000336 13547564172 0015345 0 ustar 00root root 0000000 0000000 #!/bin/sh -x
# Run shellcheck on scripts under bin and scripts directories
# shellcheck disable=SC2046,SC2038
shellcheck $(find .copr/ scripts/ bin/ src/lib/libast/tests | xargs file | grep "shell script" | cut -d':' -f1)
ast-2020.0.0/bin/style 0000775 0000000 0000000 00000013022 13547564172 0014374 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ksh
#
# Usage: bin/style [all | directory_or_filename...]
#
# Run the source through `clang-format`. If invoked with `all` then all the
# src/cmd/ksh93 source files will be linted. If invoked with one or more path
# names they will be restyled. If the pathname is a directory all *.c and *.h
# files inside it will be restyled. Otherwise any uncommitted source files are
# restyled. If there is no uncommitted change then the files in the most
# recent commit are restyled.
#
# shellcheck disable=SC2207
# Note: Disable SC2207 warning for the entire file since setting IFS to just
# newline makes it safe to handle file names with spaces.
IFS=$'\n'
# This is the minimum clang-format version we require. It is possible that
# older versions will produce results consistent with the latest stable version
# (7.0.0 as I write this). But we know that version 3.8.0 that is included in
# some distros (e.g., OpenSuse 42) does not produce compatible results.
#
# Requiring a compatible minimum version avoids pointless thrashing of the
# code style due to some people running this script on systems with a version
# of clang-format that is too old. Note that version 6.0.1 produces the same
# result as 7.0.0, the current stable release, so make that the minimum.
typeset -r MIN_CFORMAT_VER=6.0.1
typeset -r MAX_CFORMAT_VER=7.0.0
typeset all=no
typeset git_clang_format=no
typeset -a c_files=()
typeset -a files=()
function semver {
echo $1 | awk '{ split($1, v, "."); printf "%d%03d%03d\n", v[1], v[2], v[3] }'
}
# Deal with any CLI flags.
while [[ "${#}" -ne 0 ]]
do
case "${1}" in
--all | all )
all=yes
;;
* )
break
;;
esac
shift
done
if [[ ${all} == yes && "${#}" -ne 0 ]]
then
echo "Unexpected arguments: '${1}'" >&2
exit 1
fi
if command -v clang-format > /dev/null
then
cformat_ver=$(clang-format --version | awk '{ print $3 }')
if [[ $(semver $cformat_ver) -lt $(semver $MIN_CFORMAT_VER) ]]
then
echo
echo "ERROR: clang-format version $cformat_ver less than min required $MIN_CFORMAT_VER"
echo
exit 1
fi
if [[ $(semver $cformat_ver) -gt $(semver $MAX_CFORMAT_VER) ]]
then
echo
echo "ERROR: clang-format version $cformat_ver greater than max allowed $MAX_CFORMAT_VER"
echo
exit 1
fi
else
echo
echo 'ERROR: Cannot find clang-format command'
echo
exit 1
fi
if [[ ${all} == yes ]]
then
if [[ "$(git status --porcelain --short --untracked-files=all)" != "" ]]
then
echo >&2
echo 'You have uncommitted changes. Cowardly refusing to restyle the entire code base.' >&2
echo 'We do not want to include style cleanups unrelated to your work in progress.' >&2
echo 'It should be sufficient to simply run `bin/style` to fix issues with your wip.' >&2
echo >&2
exit
fi
files=( $(find src -name "*.h" -o -name "*.c") )
elif [[ "${#}" -ne 0 ]]
then
for next_file in "$@"
do
if [[ -f ${next_file} ]]
then
files+=( "${next_file}" )
elif [[ -d ${next_file} ]]
then
files+=( $(find "${next_file}" -name "*.h" -o -name "*.c") )
fi
done
else
# We haven't been asked to reformat all the source or specific files. If there are
# uncommitted changes reformat those using `git clang-format`. Else reformat the
# files in the most recent commit. Select cached files, modified but not cached,
# and untracked files.
files=( $(git diff-index --cached HEAD --name-only) )
files+=( $(git ls-files --exclude-standard --others --modified) )
if [[ "${#files[@]}" -ne 0 ]]
then
# Pending changes so restyle just the regions modified.
git_clang_format=yes
else
# No pending changes so restyle the files in the most recent commit.
files=( $(git diff-tree --no-commit-id --name-only -r HEAD) )
fi
fi
# Filter out non C source files.
for file in "${files[@]}"
do
case "${file}" in
*.c | *.h )
if [[ -f "${file}" ]]
then
c_files+=( "${file}" )
fi
;;
esac
done
# Run the C reformatter if we have any C files
if [[ "${#c_files[@]}" -eq 0 ]]
then
if [ "$STAGE_STYLE_FIXUPS" = 1 ]
then
# We're presumably being run from a git pre-commit hook so it's okay
# if no C modules are in the commit.
exit 0
fi
echo
echo 'WARNING: No C files to restyle'
echo
exit 1
fi
if [[ ${git_clang_format} == yes ]]
then
if command -v git-clang-format > /dev/null
then
echo
echo ========================================
echo Running git-clang-format
echo ========================================
git add "${c_files[@]}"
git-clang-format
else
echo
echo 'ERROR: Cannot find git-clang-format command'
echo
exit 1
fi
else
echo
echo ========================================
echo Running clang-format
echo ========================================
for file in "${c_files[@]}"
do
cp "${file}" "${file}.new" # preserves mode bits
clang-format "${file}" >"${file}.new"
if cmp -s "${file}" "${file}.new"
then
rm "${file}.new"
else
echo "${file} was NOT correctly formatted"
mv "${file}.new" "${file}"
fi
done
fi
# This feature is meant to be used from a git pre-commit hook.
if [ "$STAGE_STYLE_FIXUPS" = 1 ]
then
git add "${c_files[@]}"
fi
ast-2020.0.0/bin/trigger-app-compat-tests.sh 0000775 0000000 0000000 00000000704 13547564172 0020512 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Get current branch name
# shellcheck disable=SC1117
current=$(git rev-parse --abbrev-ref HEAD | tr -d "\n")
git branch -D application_compatibility 2>/dev/null
git checkout -b application_compatibility
# Use custom .travis.yml file
cp app-compat-travis.yml .travis.yml
git commit -a -m "Trigger application compatibility tests"
git push --force -u origin application_compatibility
# Switch back to previous branch
git checkout "$current"
ast-2020.0.0/bin/trigger-coverity-scan.sh 0000775 0000000 0000000 00000000724 13547564172 0020101 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Get current branch name
# shellcheck disable=SC1117
current=$(git rev-parse --abbrev-ref HEAD | tr -d "\n")
# Coverity scan is triggered only for coverity_scan branch
git branch -D coverity_scan 2>/dev/null
git checkout -b coverity_scan
# Use custom .travis.yml file for coverity
cp coverity-travis.yml .travis.yml
git commit -a -m "Trigger coverity scan"
git push --force -u origin coverity_scan
# Switch back to previous branch
git checkout "$current"
ast-2020.0.0/bin/upload-release.sh 0000775 0000000 0000000 00000004334 13547564172 0016555 0 ustar 00root root 0000000 0000000 #!/bin/bash
set -x
SELF="$0"
TAG="$1"
TOKEN="$2"
NV="ksh-${TAG}"
usage() {
printf "Usage: %s TAG TOKEN\n" "$SELF" >&2
exit 1
}
die() {
printf "%s: error: %s\n" "$SELF" "$*" >&2
exit 1
}
# check arguments
test "$TAG" = "$(git describe --tags "$TAG")" || usage
test -n "$TOKEN" || usage
# dump a tarball
SRC_TAR="${NV}.tar"
git archive --prefix="$NV/" --format="tar" HEAD -- . > "$SRC_TAR" \
|| die "failed to export sources"
# produce .tar.gz
TAR_GZ="${NV}.tar.gz"
gzip -c "$SRC_TAR" > "$TAR_GZ" || die "failed to create $TAR_GZ"
# produce .tar.xz
TAR_XZ="${NV}.tar.xz"
xz -c "$SRC_TAR" > "$TAR_XZ" || die "failed to create $TAR_XZ"
# sign the tarballs
for file in "$TAR_GZ" "$TAR_XZ"; do
gpg --armor --detach-sign "$file" || die "tarball signing failed"
test -f "${file}.asc" || die "tarball signature was not created"
done
# I did these steps manually during ksh-2020.0.0 alpha release.
# TODO: Find out why these API calls fail
# file to store response from GitHub API
# JSON="./${NV}-github-release.js"
#
# # create a new release on GitHub
# curl "https://api.github.com/repos/att/ast/releases" \
# -o "$JSON" --fail --verbose \
# --header "Authorization: token $TOKEN" \
# --data '{
# "tag_name": "'"$TAG"'",
# "target_commitish": "master",
# "name": "'"$NV"'",
# "draft": false,
# "prerelease": true
# }' || exit $?
#
# # parse upload URL from the response
# UPLOAD_URL="$(grep '^ *"upload_url": "' "$JSON" \
# | sed -e 's/^ *"upload_url": "//' -e 's/{.*}.*$//')"
# grep '^https://uploads.github.com/.*/assets$' <<< "$UPLOAD_URL" || exit $?
#
# # upload both .tar.gz and .tar.xz
# for comp in gzip xz; do
# file="${NV}.tar.${comp:0:2}"
# curl "${UPLOAD_URL}?name=${file}" \
# -T "$file" --fail --verbose \
# --header "Authorization: token $TOKEN" \
# --header "Content-Type: application/x-${comp}" \
# || exit $?
# done
#
# # upload signatures
# for file in "${TAR_GZ}.asc" "${TAR_XZ}.asc"; do
# curl "${UPLOAD_URL}?name=${file}" \
# -T "$file" --fail --verbose \
# --header "Authorization: token $TOKEN" \
# --header "Content-Type: text/plain" \
# || exit $?
# done
ast-2020.0.0/config_ast.h.in 0000664 0000000 0000000 00000026120 13547564172 0015433 0 ustar 00root root 0000000 0000000 // These are all the symbols defined by the legacy Nmake/iffe based build
// system I could identify. Some of them may no longer be relevant because we
// have pruned a lot of the code that is not relevant to building the `ksh`
// and related binaries and libraries. Nonetheless, those symbols are included
// here just in case we've overlooked something in the transition to the Meson
// build tool.
//
// I am explicitly including all such symbols to help us identify areas where we
// may be missing a platform feature test. Such symbols will show up as
// `#undef` comments after the Meson config step has been run to produce the
// `build/config_ast.h` header. There will be a lot of false positives until
// we have removed symbols that are known to no longer be relevant.
//
// TODO: At some point in the future (e.g., 2019-01-01) irrelevant items in
// the following list can be removed and the preceding paragraph removed.
// The following symbols are in lexical order within a given prefix; e.g.,
// `_lib_`. But the prefix groups are not in lexical order. The esoteric
// prefix groups are listed first. The standard prefix symbols (e.g., `_sys_`,
// `_hdr_`, etc.) based on tests like `cc.has_function()` or `cc.has_header()`
// are enumerated later.
#ifndef _CONFIG_AST_H
#define _CONFIG_AST_H 1
#include
#include
#include
#define _GNU_SOURCE 1
#define _UNIV_DEFAULT "ucb" // https://github.com/att/ast/issues/370
#define _fd_self_dir_fmt "/proc/self/fd/%d%s%s"
#define _fd_pid_dir_fmt "/proc/%d/fd/%d%s%s"
// These are atypical platform symbols with respect to how they are
// determined. They are either hardcoded or not determined via the usual
// platform feature detection and naming conventions.
#mesondefine DEBUG_BUILD
#mesondefine MESON_BUILD
#mesondefine OSNAME
#mesondefine HOSTTYPE
#mesondefine BASH_MACHTYPE
#mesondefine STAT_ST_MTIM
#mesondefine STAT_ST_MTIMESPEC
#mesondefine CONF_LIBPATH
#mesondefine CONF_LIBPREFIX
#mesondefine CONF_LIBSUFFIX
#mesondefine N_PROC
#mesondefine _PROC_PROG
#mesondefine _DARWIN_C_SOURCE
#mesondefine _WSL_
#mesondefine _ast_sizeof_int
#mesondefine _ast_sizeof_long
#mesondefine _ast_sizeof_off_t
#mesondefine _ast_sizeof_pointer
#mesondefine _ast_sizeof_size_t
#mesondefine _ast_sizeof_int32_t
#mesondefine _ast_sizeof_wchar_t
#mesondefine _cmd_tput
#mesondefine _dll_DYNAMIC
#mesondefine _DLL_NEXT_PATH
#mesondefine _may_use_threads
#mesondefine _more_long_int
#mesondefine _more_void_int
#mesondefine _wchar_t_is_int
#mesondefine _pth_addr2line
#mesondefine _pth_atos
#mesondefine _pth_ed
#mesondefine _pipe_rw
#mesondefine _socketpair_shutdown_mode
#mesondefine _pipe_socketpair
#mesondefine isnanl
#mesondefine const_const_fts_open
#mesondefine MAX_SIGNUM
#mesondefine has_dev_fd
// What follows are all the symbols that should be based on Meson feature
// tests like `cc.has_header()` and `cc.find_library()`.
#mesondefine _hdr_dl
#mesondefine _hdr_dlfcn
#mesondefine _hdr_dll
#mesondefine _hdr_execargs
#mesondefine _hdr_execinfo
#mesondefine _hdr_filio
#mesondefine _hdr_float
#mesondefine _hdr_mach_o_dyld
#mesondefine _hdr_malloc
#mesondefine _hdr_math
#mesondefine _hdr_mman
#mesondefine _hdr_rld_interface
#mesondefine _hdr_stdlib
#mesondefine _hdr_sys_filio
#mesondefine _hdr_sys_ldr
#mesondefine _hdr_sys_pstat
#mesondefine _hdr_sys_ptem
#mesondefine _hdr_sys_stream
#mesondefine _lib_clock_gettime
#mesondefine _lib_creat64
#mesondefine _lib_dllload
#mesondefine _lib_dlopen
#mesondefine _lib_eaccess
#mesondefine _lib_euidaccess
#mesondefine _lib_faccessat
#mesondefine _lib_fdopendir
#mesondefine _lib_fstat64
#mesondefine _lib_fstatvfs64
#mesondefine _lib_ftruncate
#mesondefine _lib_ftruncate64
#mesondefine _lib_getexecname
#mesondefine _lib_getrusage
#mesondefine _lib_gettimeofday
#mesondefine _lib_lchmod
#mesondefine _lib_lchmod_fchmodat_fallback
#mesondefine _lib_loadbind
#mesondefine _lib_lseek64
#mesondefine _lib_lstat
#mesondefine _lib_lstat64
#mesondefine _lib_memcntl
#mesondefine _lib_mmap64
#mesondefine _lib_mkostemp
#mesondefine _lib_open64
#mesondefine _lib_opendir
#mesondefine _lib_pipe2
#mesondefine _lib_poll
#mesondefine _lib_posix_spawn
#mesondefine _lib_posix_spawnattr_setfchdir
#mesondefine _lib_posix_spawnattr_setsid
#mesondefine _lib_posix_spawnattr_setumask
#mesondefine _lib_pstat
#mesondefine _lib_rewinddir
#mesondefine _lib_sigqueue
#mesondefine _lib_socket
#mesondefine _lib_socketpair
#mesondefine _lib_spawn
#mesondefine _lib_spawn_mode
#mesondefine _lib_spawnve
#mesondefine _lib_spawnvex
#mesondefine _lib_statvfs
#mesondefine _lib_statvfs64
#mesondefine _lib_strlcat
#mesondefine _lib_sync
#mesondefine _lib_syncfs
#mesondefine _lib_sysinfo
#mesondefine _lib_truncate64
#mesondefine _lib_universe
#mesondefine _lib_utime
#mesondefine _lib_utimensat
#mesondefine _lib_expm1l
#mesondefine _lib_log1pl
#mesondefine _lib_remainderl
#mesondefine _lib_log2l
#mesondefine _lib_tgammal
#mesondefine _lib_lgammal
#mesondefine _mem_d_fileno_dirent
#mesondefine _mem_d_ino_dirent
#mesondefine _mem_d_namlen_dirent
#mesondefine _mem_d_reclen_dirent
#mesondefine _mem_d_type_dirent
#mesondefine _mem_base_rel_utsname
#mesondefine _mem_idnumber_utsname
#mesondefine _mem_m_type_utsname
#mesondefine _mem_pgroup_inheritance
// These symbols are from src/lib/libast/include/ast_common.h that was
// generated on a Linux platform by the legacay IFFE mechanism. They may not
// be correct for other platforms.
//
// TODO: Convert these to proper feature tests.
#define _ast_int8_t long
#define _ast_intmax_t _ast_int8_t
#mesondefine _ast_intmax_long
#define _ast_fltmax_t long double
#mesondefine _has_sighandler_t
#if !_has_sighandler_t
typedef void (*sighandler_t)(int);
#endif
#if DEBUG_BUILD
// If we're doing a debug build don't have any static (module private) functions.
// This is needed on most platforms for dladdr() to give us an accurate backtrace.
#define static_fn
#else
#define static_fn static
#endif
// This is a macro that can be used to silence "unused parameter" warnings from the compiler for
// functions which need to accept parameters they do not use because they need to be compatible with
// an interface. It's similar to the Python idiom of doing `_ = param` at the top of a function in
// the same situation.
//
// Do not use this for `param` symbols that have side-effects when evaluated. It should only be used
// for function parameters. And even then only at the very top of a function definition.
#define UNUSED(param) \
do { \
(void)(param); \
} while (0)
// If running under the oclint tool try to suppress some platform specific warnings.
// For example, on macOS many commonly used functions are defined in terms of macros
// that contain expressions which always evaluate true or false.
#if _OCLINT_
#undef strcat
#undef strcpy
#undef strlcat
#undef strlcpy
#undef memcpy
#undef memmove
#endif // _OCLINT_
// Types that are needed in many places but which are difficult to define in the header containing
// the structure definition due to circular includes that would otherwise result.
typedef struct Namval Namval_t; // from name.h
typedef struct Shell_s Shell_t; // from shell.h
typedef struct Shbltin_s Shbltin_t; // from shcmd.h
typedef struct _shlex_ Lex_t; // from shlex.h
typedef struct _mac_ Mac_t; // from macro.c
typedef struct pathcomp Pathcomp_t; // from path.h
typedef struct edit Edit_t; // from edit.h
typedef struct _timer Timer_t; // from timers.c
typedef struct Optdisc_s Optdisc_t; // from option.h
typedef union Shnode_u Shnode_t; // from shnodes.h
typedef int (*Shbltin_f)(int, char **, Shbltin_t *);
//
// We need to wrap the malloc family of functions. That's because the
// `job_waitsafe()` function is called from an interrupt context and
// indirectly calls `malloc()`. See issue #563.
//
extern volatile bool vmbusy_flag;
#define vmbusy() vmbusy_flag
#if !NO_MALLOC_WRAPPERS
extern void *ast_malloc(size_t size);
extern void *ast_calloc(size_t count, size_t size);
extern void *ast_realloc(void *ptr, size_t size);
extern void ast_free(void *ptr);
#define malloc(s) ast_malloc(s)
#define calloc(c, s) ast_calloc(c, s)
#define realloc(p, s) ast_realloc(p, s)
#define free(p) ast_free(p)
// This is not used and is not expected to be used so make sure if it is used
// it causes a problem.
#define valloc(s) valloc_has_no_ast_wrapper(s)
#endif // !NO_MALLOC_WRAPPERS
extern char *sh_getenv(const char *name);
#define getenv(x) sh_getenv(x)
// We need prototypes for each fallback implementation if the system doesn't
// provide the function.
#if !_lib_eaccess
extern int eaccess(const char *pathname, int mode);
#endif
#if !_lib_mkostemp
extern int mkostemp(char *template, int oflags);
#endif
#if !_lib_strlcat
extern size_t strlcat(char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
#endif
#if _lib_lchmod_fchmodat_fallback
extern int lchmod(const char *path, mode_t mode);
#endif
// This is useful for printing debugging messages that are tagged with useful
// information such as the current file, line number, function name, and
// duration since the previous debug message. You must pass a format string
// even if it is the empty, "", string.
extern void _dprintf(const char *fname, int lineno, const char *funcname, const char *fmt, ...);
#define DPRINTF(fmt, ...) _dprintf(__FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
// Debug print of a `struct Value` object.
//
// Note that the function prototype uses a `const void*` because we can't use
// `struct Value*` here as the src/ksh93/include/name.h header which defines
// it can't be included before this header.
extern void _dprint_vtp(const char *file_name, int lineno, const char *func_name,
int level, const char *var_name, const void *vp);
#define DPRINT_VT(vt) _dprint_vtp(__FILE__, __LINE__, __FUNCTION__, 0, #vt, &(vt))
#define DPRINT_VTP(vtp) _dprint_vtp(__FILE__, __LINE__, __FUNCTION__, 0, #vtp, vtp)
// Debug print of a `struct Namval` object.
//
// Note that the function prototype uses a `const void*` because we can't use
// `struct Namval*` here as the src/ksh93/include/name.h header which defines
// it can't be included before this header.
extern void _dprint_nvp(const char *file_name, const int lineno, const char *func_name,
int level, const char *var_name, const void *vp);
#define DPRINT_NV(nv) _dprint_nvp(__FILE__, __LINE__, __FUNCTION__, 0, #nv, &(nv))
#define DPRINT_NVP(nvp) _dprint_nvp(__FILE__, __LINE__, __FUNCTION__, 0, #nvp, nvp)
// Debug print of a `struct Namref` object.
//
// Note that the function prototype uses a `const void*` because we can't use
// `struct Namref*` here as the src/ksh93/include/name.h header which defines
// it can't be included before this header.
extern void _dprint_nrp(const char *file_name, const int lineno, const char *func_name,
int level, const char *var_name, const void *vp);
#define DPRINT_NR(nr) _dprint_nrp(__FILE__, __LINE__, __FUNCTION__, 0, #nr, &(nr))
#define DPRINT_NRP(nrp) _dprint_nrp(__FILE__, __LINE__, __FUNCTION__, 0, #nrp, nrp)
// This can be used to convert an arbitrary nvflag bit mask to a symbolic form.
extern const char *nvflag_to_syms(uint64_t nvflag);
#endif
ast-2020.0.0/coverity-travis.yml 0000664 0000000 0000000 00000002656 13547564172 0016446 0 ustar 00root root 0000000 0000000 sudo: required
language: c
env:
global:
# COVERITY_SCAN_TOKEN
- secure: "BsKgvr97ykXKfTwCHQshe4pUMsPySrbqDr1LC+8ixKap3GOHO9wz8sMlPHtIuYjMeJ7sRHiNpDcZ+GC3j3uwj3Wn+2mIIcPF/lefw6KZbxSmuPwELfXdI3MCZwOgZr2KfnsAPMbv7fWFTHwLYUCler8WI+ko9Yvc/ZC1w7hEiP8="
before_install:
- sudo apt-get update
- sudo apt-get install python3-pip
- sudo apt-get install python3-setuptools
- sudo pip3 install meson==0.44.0
# Ubuntu repositories have older version of ninja
- wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
- unzip ninja-linux.zip
- mv ninja ~/bin
script:
- exit 0
addons:
coverity_scan:
# GitHub project metadata
project:
name: ksh
# Where email notification of build analysis results will be sent
notification_email: svashisht@redhat.com
# Commands to prepare for build_command
build_command_prepend: meson -Dbuild-api-tests=false build
# The command that will be added as an argument to "cov-build" to
# compile your project for analysis,
build_command: ninja -C build
# Pattern to match selecting branches that will run analysis. We
# recommend leaving this set to 'coverity_scan'. Take care in resource
# usage, and consider the build frequency allowances per
# https://scan.coverity.com/faq#frequency
branch_pattern: coverity_scan
ast-2020.0.0/etc/ 0000775 0000000 0000000 00000000000 13547564172 0013313 5 ustar 00root root 0000000 0000000 ast-2020.0.0/etc/README 0000664 0000000 0000000 00000000274 13547564172 0014176 0 ustar 00root root 0000000 0000000 This directory is for files needed by the commands in the `bin` or `scripts`
directory. These will typically be config files and the like for the tools
used by those commands and scripts.
ast-2020.0.0/etc/hdrs.c 0000664 0000000 0000000 00000000246 13547564172 0014421 0 ustar 00root root 0000000 0000000 // This is a trivial program used by the `lint` script to find out where the
// compiler thinks the system headers live.
#include
int main() { return 0; }
ast-2020.0.0/etc/iwyu.bsd.map 0000664 0000000 0000000 00000061066 13547564172 0015567 0 ustar 00root root 0000000 0000000 # Map file for the include-what-you-use tool on macOS. For some reason
# the version installed by HomeBrew doesn't have useful mappings for the
# system provided headers. This also has mappings for FreeBSD.
[
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["<_wctype.h>", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["<_types/_intmax_t.h>", "public", "", "public"] },
{ include: ["<_types/_uintmax_t.h>", "public", "", "public"] },
{ include: ["<_types/_uint8_t.h>", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["<_types/_uint64_t.h>", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["", "public", "", "public"] },
{ include: ["<__functional_base>", "public", "", "public"] },
{ include: ["<__functional_base>", "public", "", "public"] },
{ include: ["<__functional_base>", "public", "", "public"] },
{ include: ["<__tree>", "public", "