### cgrep Options Source: https://github.com/legionus/libshell/blob/master/utils/cgrep.md Lists and describes the available command-line options for cgrep, such as defining patterns, ignoring case, controlling output, and accessing help. ```bash -e, --pattern=PATTERN use PATTERN as the pattern; -f, --file=FILE obtain patterns from FILE, one per line; -i, --ignore-case ignore case distinctions in the PATTERN; -a, --all-lines don’t suppress unmatched lines; -o, --one-match highlight only first match of PATTERN; -E, --regexp-extended use extended regular expressions in the PATTERN; -v, --verbose print a message for each action; -V, --version print program version and exit; -h, --help show this text and exit. ``` -------------------------------- ### cgrep Command Line Usage Source: https://github.com/legionus/libshell/blob/master/utils/cgrep.md Demonstrates the basic syntax for using the cgrep command with patterns and input files. It covers both single and multiple pattern definitions. ```bash cgrep [options] PATTERN [--] [FILE...] cgrep [options] -e PATTERN [-e PATTERN1...] [--] [FILE...] ``` -------------------------------- ### cgrep Pattern Format Source: https://github.com/legionus/libshell/blob/master/utils/cgrep.md Defines the structure for specifying colorization patterns, including pattern text, type (foreground/background), modifiers (bold, italic, etc.), and color names. ```plaintext PATTERN := '/GREP-PATTERN/ [[TYPE] MODIFICATOR COLOR]...' You can use any character instead of '/'. TYPE := {foreground|background} or {fg|bg} COLOR := {gray|black|blue|green|cyan|red|magenta|yellow|white} MODIFICATORS := {bold|italic|underline|reverse} or {b|i|u|rev} ``` -------------------------------- ### Calculate 2^62 in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Demonstrates the calculation of 2 to the power of 62 across different shell environments. It showcases how shells interpret and display large integer values, with results typically being consistent for this value. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %d\n" "$0" $(( 1 << 62 ))'; done OUT: zsh: 4611686018427387904 OUT: dash: 4611686018427387904 OUT: bash: 4611686018427387904 OUT: ksh: 4611686018427387904 OUT: lksh: 4611686018427387904 OUT: ash: 4611686018427387904 ``` -------------------------------- ### Calculate 2^63 in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Illustrates the calculation of 2 to the power of 63 in different shells. This commonly results in the minimum signed 64-bit integer value due to two's complement representation. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %s\n" "$0" $(( 1 << 63 ))'; done OUT: zsh: -9223372036854775808 OUT: dash: -9223372036854775808 OUT: bash: -9223372036854775808 OUT: ksh: -9223372036854775808 OUT: lksh: -9223372036854775808 OUT: ash: -9223372036854775808 ``` -------------------------------- ### Shell Arithmetic with String Expressions for Large Integers Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Demonstrates using string expressions like "(0x7fffffffffffffff + 1)" within shell arithmetic to represent large numbers, showing how different shells parse and evaluate these. ```shell $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v=$(( 0x7fffffffffffffff + 1 )); printf "OUT: %4s: %x\n" $0 $(( $v ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: f333333333333334 OUT: dash: 8000000000000001 OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v="(0x7fffffffffffffff + 1)"; printf "OUT: %4s: %x\n" $0 $(( $v ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: f333333333333334 OUT: dash: 8000000000000000 OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 ``` -------------------------------- ### Shell Integer Arithmetic with Bit Shifts Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Compares how different shells handle the calculation of 1 << 62 and 1 << 63. It shows the output and potential truncation issues when exceeding maximum representable values in some shells. ```shell $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v=$(( 1 << 62 )); printf "OUT: %4s: %x\n" $0 $(( $v ))'; done OUT: zsh: 4000000000000000 OUT: dash: 4000000000000000 OUT: bash: 4000000000000000 OUT: ksh: 4000000000000000 OUT: lksh: 4000000000000000 OUT: ash: 4000000000000000 $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v=$(( 1 << 63 )); printf "OUT: %4s: %x\n" $0 $(( $v ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: f333333333333334 OUT: dash: 8000000000000001 OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 ``` -------------------------------- ### Commit with Signed-off-by line Source: https://github.com/legionus/libshell/blob/master/CONTRIBUTING.md This command adds the 'Signed-off-by' line to your commit, which is a mandatory requirement for contributing to the libshell project. It certifies that you have the right to submit the work under the project's open source license. ```bash git commit -s ``` -------------------------------- ### Calculate (2^63 - 1) + 2 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Tests the hexadecimal representation when adding two to the maximum positive 64-bit signed integer in different shells. This further highlights potential parsing differences. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 0x7fffffffffffffff + 2 ))'; done OUT: zsh: 8000000000000001 OUT: dash: 8000000000000001 OUT: bash: 8000000000000001 OUT: ksh: 8000000000000001 OUT: lksh: 8000000000000001 OUT: ash: 8000000000000001 ``` -------------------------------- ### Calculate (2^63 - 1) + 3 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Evaluates the hexadecimal output when adding three to the maximum positive 64-bit signed integer across various shells, observing any display anomalies. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 0x7fffffffffffffff + 3 ))'; done OUT: zsh: 8000000000000002 OUT: dash: 8000000000000002 OUT: bash: 8000000000000002 OUT: ksh: 8000000000000002 OUT: lksh: 8000000000000002 OUT: ash: 8000000000000002 ``` -------------------------------- ### Calculate (2^63 - 1) + (2^63 - 1) + 1 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Tests the hexadecimal result of summing the maximum positive 64-bit signed integer twice and adding one, across different shells, to identify parsing behaviors. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 0x7fffffffffffffff + 0x7fffffffffffffff + 1 ))'; done OUT: zsh: ffffffffffffffff OUT: dash: ffffffffffffffff OUT: bash: ffffffffffffffff OUT: ksh: ffffffffffffffff OUT: lksh: ffffffffffffffff OUT: ash: ffffffffffffffff ``` -------------------------------- ### Calculate (2^63 - 1) + 1 in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Tests the calculation of the maximum positive 64-bit signed integer plus one across different shells. This operation often results in the minimum negative 64-bit signed integer due to overflow. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %s\n" "$0" $(( 0x7fffffffffffffff + 1 ))'; done OUT: zsh: -9223372036854775808 OUT: dash: -9223372036854775808 OUT: bash: -9223372036854775808 OUT: ksh: -9223372036854775808 OUT: lksh: -9223372036854775808 OUT: ash: -9223372036854775808 ``` -------------------------------- ### Calculate (2^63 - 1) + 1 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Examines the hexadecimal output when adding one to the maximum positive 64-bit signed integer in various shells. Similar to direct calculation of 2^63, some shells might show variations in display. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 0x7fffffffffffffff + 1 ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: f333333333333334 OUT: dash: 8000000000000000 OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 ``` -------------------------------- ### Calculate 2^63 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Shows the hexadecimal representation of 2 to the power of 63 across different shells. Some shells correctly display '8000000000000000', while others, like zsh, may truncate or display differently due to parsing nuances. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 1 << 63 ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: f333333333333334 OUT: dash: 8000000000000000 OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 ``` -------------------------------- ### Shell Integer Arithmetic with Hexadecimal Values Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Tests how different shells interpret and display large hexadecimal values, including 0x7fffffffffffffff and 0x8000000000000000, and their behavior in arithmetic operations. ```shell $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v=0x7fffffffffffffff; printf "OUT: %4s: %x\n" $0 $(( $v ))'; done OUT: zsh: 7fffffffffffffff OUT: dash: 7fffffffffffffff OUT: bash: 7fffffffffffffff OUT: ksh: 7fffffffffffffff OUT: lksh: 7fffffffffffffff OUT: ash: 7fffffffffffffff $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'v=0x8000000000000000; printf "OUT: %4s: %x\n" $0 $(( $v ))'; done zsh:1: number truncated after 15 digits: 8000000000000000 OUT: zsh: 800000000000000 OUT: dash: 7fffffffffffffff OUT: bash: 8000000000000000 OUT: ksh: 8000000000000000 OUT: lksh: 8000000000000000 OUT: ash: 8000000000000000 ``` -------------------------------- ### Parse -9223372036854775808 as decimal in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Tests the decimal interpretation of the minimum signed 64-bit integer across different shells. Zsh again shows a truncation warning, and its output differs from other shells which correctly represent the value. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %d\n" "$0" $(( -9223372036854775808 ))'; done zsh:1: number truncated after 18 digits: 9223372036854775808 OUT: zsh: -922337203685477580 OUT: dash: -9223372036854775807 OUT: bash: -9223372036854775808 OUT: ksh: -9223372036854775808 OUT: lksh: -9223372036854775808 OUT: ash: -9223372036854775808 ``` -------------------------------- ### Parse 0x8000000000000000 as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Examines the hexadecimal output when parsing the smallest negative 64-bit signed integer (0x8000000000000000) in different shells. Zsh shows a truncation warning, while dash produces a positive value, unlike bash and others. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %s\n" "$0" $(( 0x8000000000000000 ))'; done zsh:1: number truncated after 15 digits: 8000000000000000 OUT: zsh: 576460752303423488 OUT: dash: 9223372036854775807 OUT: bash: -9223372036854775808 OUT: ksh: -9223372036854775808 OUT: lksh: -9223372036854775808 OUT: ash: -9223372036854775808 ``` -------------------------------- ### Parse 0xffffffffffffffff as hex in various shells Source: https://github.com/legionus/libshell/blob/master/Documentation/int64_max.md Investigates how different shells parse the hexadecimal representation of the maximum unsigned 64-bit integer (all ones). This reveals significant variations, with zsh truncating and dash treating it as a smaller value. ```sh $ for sh in zsh dash bash ksh lksh "busybox ash"; do $sh -c 'printf "OUT: %4s: %x\n" "$0" $(( 0xffffffffffffffff ))'; done zsh:1: number truncated after 15 digits: ffffffffffffffff OUT: zsh: fffffffffffffff OUT: dash: 7fffffffffffffff OUT: bash: ffffffffffffffff OUT: ksh: ffffffffffffffff OUT: lksh: ffffffffffffffff OUT: ash: ffffffffffffffff ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.