New answers tagged

0

In default Debian, sh is a link to dash (not bash). Dash fits more closely the POSIX behavior for "Brace Expansion". Bash has this documented difference with historical sh (from man bash): Brace expansion introduces a slight incompatibility with historical versions of sh. sh does not treat opening or closing braces specially when they appear as part of ...


2

Bash can be told to disable brace expansion with set +B, which is the inverse of set -B: -B The shell will perform brace expansion (see Brace Expansion). This option is on by default. You can also provide this on the command line when launching the shell: $ bash +B -c 'echo {a,b,c}' {a,b,c} You can combine this with the --posix or set -o posix ...


0

According to the Bash Reference Manual (http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html), the --posix flag "will cause Bash to conform more closely to the POSIX standard". It seems full POSIX compliance isn't an option. As for the difference in behavior, I believe you'll find /bin/sh is a symlink to /bin/bash on Fedora. Debian ...


3

Pattern matching is done with case statements in all Bourne-like shells. is_absolute() { case "$1" in ///* | //) true;; //*) false;; # on some systems, //foo is special and is # not an absolute path. // alone is / /*) true;; *) false esac } Remove the first two entries on systems that don't ...


1

Ok, here it is answered by pierre schmitz, thx nymous for the link: openssl, phar and posix modules are now built in php7 core. Remove the corresponding directives from your php.ini, e.g. ;extension=openssl.so. php-xcache is incompatible with php7, remove package, the project seems dead. full list of 3rd party package status: | Package | Status ...


0

uname - print system information uname means unix name uname has options to view specific information. hostname return machine name same as uname -n


0

php no longer has support for that stuff in modules. Look at this article https://pierre-schmitz.com/php-7-on-arch-linux/


1

Just check the first character of the string using substring syntax: [[ ${var:0:1} = / ]] || return 1


1

POSIX define absolute path as a pathname beginning with a single or more than two /. There's a utility called pathchk to check pathname, so you can do: [ -z "${1%%/*}" ] && pathchk -pP "$1" -p tells pathchk to perform check for path that: Is longer than 256 bytes (See _POSIX_PATH_MAX) Contains any component longer than 14 bytes (See ...


2

If by absolute path you mean that it starts with /, and we are talking about bash (as tag suggest): $ var1='/tmp/foo' $ var2='tmp/foo' $ [[ "$var1" =~ ^/ ]] && echo yes || echo no yes $ [[ "$var2" =~ ^/ ]] && echo yes || echo no no


2

An absolute path would begin with / not contain any /../ or /./ not begin with ../ or ./ not end with /.. or /. so you could do this (portably) with a case statement: case "x$1" in (x*/..|x*/../*|x../*|x*/.|x*/./*|x./*) rc=1 ;; (x/*) rc=0 ;; (*) rc=1 ;; esac return $rc This ...


5

[ "$1" != "${1#/}" ] || return 1 There may be a better way (that's why I asked). This code strips off any leading / in $1 and checks that the result is not the same as $1 itself.


5

Collation elements are usually referenced in the context of sorting. In many languages, collation (sorting like in a dictionary) is not only done per-character. For instance, in Czech, ch doesn't sort between cg and ci like it would in English, but is considered as a whole for sorting. It is a collating element (we can't refer to a character here, character ...


0

This is usefull when non-english (non-ascii) characters are in use. The example ch you mention is a digraph, i.e. some languages have a letter in their alphabet that is/can be represented by two letters in an English alphabet. When you use [.ch.] in a regexp, you basically say: "I expect a non-English input sequence with the digraph ch. I want my regexp to ...


2

Expansion allows for only the one variable, necessitating the temp var. However, if this is the exact use case, dirname may work for you, since it does pretty much exactly the same thing as %/*: $ foo=/lorem/ipsum; bar=dolor/sit $ dirname $foo/$bar /lorem/ipsum/dolor


0

Here's one ... workaround ... that does not set the temporary variable in the current shell: foo=/lorem/ipsum; bar=dolor/sit (tmp="$foo/$bar"; printf '%s\n' "${tmp%/*}")



Top 50 recent answers are included