summary refs log tree commit diff
path: root/lib/strings.nix
Commit message (Collapse)AuthorAge
* lib.readPathsFromFile: simplify, /cc #24036Orivej Desh2017-03-19
| | | | This part isn't needed after 36de745e1b7.
* readPathsFromFile: fixup after #23851Vladimír Čunát2017-03-19
| | | | | The final newline would produce an empty string; let's filter all empty lines as well.
* libs: make splitString also split last separator (#23851)Léo Gaspard2017-03-15
| | | | | | * libs: make splitString also split last separator * libs: add tests for splitStrings
* getVersion: first try drv.version before parsing drv.nameDomen Kožar2016-08-13
|
* fix documentation typo in lib/strings.nix (#17684)Данило Глинський (Danylo Hlynskyi)2016-08-12
|
* hasSuffix: human readable inputsDomen Kožar2016-08-10
|
* lib: add fileContents functionEric Sagnes2016-08-01
|
* lib: Make escapeShellArg more robustaszlig2016-06-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quoting various characters that the shell *may* interpret specially is a very fragile thing to do. I've used something more robust all over the place in various Nix expression I've written just because I didn't trust escapeShellArg. Here is a proof of concept showing that I was indeed right in distrusting escapeShellArg: with import <nixpkgs> {}; let payload = runCommand "payload" {} '' # \x00 is not allowed for Nix strings, so let's begin at 1 for i in $(seq 1 255); do echo -en "\\x$(printf %02x $i)" done > "$out" ''; escapers = with lib; { current = escapeShellArg; better = arg: let backslashEscapes = stringToCharacters "\"\\ ';$`()|<>\r\t*[]&!~#"; search = backslashEscapes ++ [ "\n" ]; replace = map (c: "\\${c}") backslashEscapes ++ [ "'\n'" ]; in replaceStrings search replace (toString arg); best = arg: "'${replaceStrings ["'"] ["'\\''"] (toString arg)}'"; }; testWith = escaper: let escaped = escaper (builtins.readFile payload); in runCommand "test" {} '' if ! r="$(bash -c ${escapers.best "echo -nE ${escaped}"} 2> /dev/null)" then echo bash eval error > "$out" exit 0 fi if echo -n "$r" | cmp -s "${payload}"; then echo success > "$out" else echo failed > "$out" fi ''; in runCommand "results" {} '' echo "Test results:" ${lib.concatStrings (lib.mapAttrsToList (name: impl: '' echo " ${name}: $(< "${testWith impl}")" '') escapers)} exit 1 '' The resulting output is the following: Test results: best: success better: success current: bash eval error I did the "better" implementation just to illustrate that the method of quoting only "harmful" characters results in madness in terms of implementation and performance. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @edolstra, @zimbatm
* Merge pull request #16180 from zimbatm/shell-escapingzimbatm2016-06-19
|\ | | | | Escape all shell arguments uniformly
| * Escape all shell arguments uniformlyzimbatm2016-06-12
| |
* | Remove unecessary branching on old nix versionszimbatm2016-06-17
|/ | | | | All these builtins are available since 1.10 or earlier (1.10 being the lib/minver.nix)
* lib: revert my bogus comment fixNikolay Amiantov2016-05-19
| | | | See https://github.com/NixOS/nixpkgs/commit/5445e521b6524587489c6968cc27347977b9b7b8#commitcomment-17531945
* firefox: restore gstreamer support for older firefox releasesNikolay Amiantov2016-05-19
|
* make*Path: implement via makeSearchPathOutputNikolay Amiantov2016-04-25
|
* makeSearchPathOutputs: refactor to makeSearchPathOutputNikolay Amiantov2016-04-25
|
* makeSearchPath (and derivatives): check outputUnspecifiedNikolay Amiantov2016-04-13
|
* makePerlPath: try to guess outputsNikolay Amiantov2016-04-13
|
* makeSearchPathOutputs: init functionNikolay Amiantov2016-04-13
|
* makeBinPath: guess outputsNikolay Amiantov2016-04-13
|
* Merge branch 'master' into closure-sizeVladimír Čunát2016-04-10
|\ | | | | | | | | | | Comparison to master evaluations on Hydra: - 1255515 for nixos - 1255502 for nixpkgs
| * Stronger warning against usage of splitStringEelco Dolstra2016-04-01
| |
* | Merge branch 'master' into closure-sizeVladimír Čunát2016-04-01
|\| | | | | | | | | Beware that stdenv doesn't build. It seems something more will be needed than just resolution of merge conflicts.
| * lib/strings: document all the functionszimbatm2016-03-10
| |
* | Merge branch 'staging' into closure-sizeVladimír Čunát2016-01-19
|\|
| * lib.getVersion: extend the function to cope with strings as well as derivationsPeter Simons2016-01-05
| |
* | Merge branch 'master' into closure-sizeVladimír Čunát2015-12-31
|\| | | | | | | | | TODO: there was more significant refactoring of qtbase and plasma 5.5 on master, and I'm deferring pointing to correct outputs to later.
| * lib/strings: add readPathsFromFileThomas Tuegel2015-12-16
| |
* | Merge branch 'master' into closure-sizeLuca Bruno2015-12-11
|\|
| * add makeBinPath function for abstracting away pkg/bin:pkg2/bin..Domen Kožar2015-12-10
| |
* | Merge remote-tracking branch 'origin/master' into closure-sizeLuca Bruno2015-11-25
|\|
| * lib/strings: add a `toInt` helper (close #11242)Christian Zagrodnick2015-11-25
| | | | | | | | While the function itself is pretty easy, it's not straitforward to find a way to convert string to int with nix.
* | Merge commit staging+systemd into closure-sizeVladimír Čunát2015-10-03
|\| | | | | | | Many non-conflict problems weren't (fully) resolved in this commit yet.
| * Allow options with type "package" to be store pathsEelco Dolstra2015-08-07
| | | | | | | | | | | | | | | | For example, this allows writing nix.package = /nix/store/786mlvhd17xvcp2r4jmmay6jj4wj6b7f-nix-1.10pre4206_896428c; Also, document types.package in the manual.
| * intersperse: Fix quadratic performanceEelco Dolstra2015-07-24
| |
| * Remove eqStringsEelco Dolstra2015-07-24
| | | | | | | | It's no longer needed. Also clean up some comments.
| * Use replaceStrings primopEelco Dolstra2015-07-24
| |
| * Use concatStringSep primopEelco Dolstra2015-07-24
| |
| * Rename misc.nix -> deprecated.nixEelco Dolstra2015-07-23
| |
| * Use foldl' instead of fold in some placesEelco Dolstra2015-07-23
| |
| * Issue 8152 - Reduce number of attribute set created by replaceChars.Nicolas B. Pierron2015-07-13
| |
* | systemPackages, makeLibraryPath: try to guess outputsVladimír Čunát2015-05-05
|/
* Add 'fixedWidthString' and 'fixedWidthNumber' formatting functionsNikita Mikhailov2015-03-08
|
* lib: Use arithmetic operators rather than builtins.add etc.Eelco Dolstra2014-10-05
|
* Added concatMapStringsSep and concatImapStringsSepIgor Pashev2014-08-25
| | | | | | | | | | Example: configure rewrite rules for Mediawiki RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d ${concatMapStringsSep "\n" (u: "RewriteCond %{REQUEST_URI} !^${u.urlPath}") serverInfo.serverConfig.servedDirs} RewriteRule ${if config.enableUploads
* lib: Do not take string context into accountKirill Elagin2014-06-11
| | | | Close #2883.
* lib/strings: add hasPrefix and simplify hasSuffixVladimír Čunát2014-05-13
| | | | It was discussed as a part of #2570.
* lib/strings: simplify removePrefix readabilityVladimír Čunát2014-05-13
| | | | It was discussed as a part of #2570.
* fetchFromGitHub: Use .tar.gz instead of .zipEelco Dolstra2014-05-09
| | | | Also clean up the name attribute of fetchzip derivations a bit.
* Add some primops to libEelco Dolstra2013-11-12
|
* Move pkgs/lib/ to lib/Eelco Dolstra2013-10-10