Skip to content

Commit

Permalink
Use TAB as IFS character for file-list instead of |
Browse files Browse the repository at this point in the history
This should still be understandable by most shells but significantly
less likely to appear in a filename.
  • Loading branch information
mroth committed Mar 10, 2015
1 parent 1f8daf3 commit e6a80d3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This project tries to adhere to [Semantic Versioning](http://semver.org/).
work tree status. This adds a bit if parsing complexity, but should be the
absolute most robust long term way to read things, and should enhance cross
platform support in the future.
- TODO: Use `TAB` as IFS character for file-list instead of `|`. This should
still be understandable by most shells but significantly less likely to appear
in a filename.
- Use `TAB` as IFS character for file-list instead of `|`. This should still be
understandable by most shells but significantly less likely to appear in a
filename.

## 0.0.1 - 2014-03-04
First "ready for daily usage" internal alpha version.
2 changes: 1 addition & 1 deletion commands/inits/data/status_shortcuts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ scmpuff_status() {

# Export numbered env variables for each file
scmpuff_clear_vars
IFS="|"
IFS=$'\t'
local e=1
for file in $files; do
export $scmpuff_env_char$e="$file"
Expand Down
12 changes: 6 additions & 6 deletions commands/status/statuslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ func (sl StatusList) printStatus(includeParseData, includeStatusOutput bool) {
b.Flush()
}

// - machine readable string for env var parsing of file list
// - same format that smb_breeze uses (but without preceding @@FILES thing that
// creates extra shell parsing mess)
// - needs to be returned in same order that file lists are outputted to screen,
// otherwise env vars won't match UI.
// Machine readable string for environment variable parsing of file list in
// the scmpuff_status() shell script.
//
// Needs to be returned in same order that file lists are outputted to screen,
// otherwise env vars won't match UI.
func (sl StatusList) dataForParsing() string {
items := make([]string, sl.numItems())
for i, si := range sl.orderedItems() {
items[i] = si.fileAbsPath
}
return strings.Join(items, "|")
return strings.Join(items, "\t")
}

// Returns the banner string to be used for printing.
Expand Down
4 changes: 0 additions & 4 deletions features/command_expand.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ Feature: command expansion at command line
| hi mom.txt | hi\ mom.txt |
| "x.txt | \"x.txt |

@wip
Scenario: Don't get screwed up if filename contains a | symbol
Given PENDING

Scenario: Allow user to specify --relative paths
Given a directory named "foo"
And a directory named "foo/bar"
Expand Down
19 changes: 19 additions & 0 deletions features/shell_functions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ Feature: scmpuff_status function
| bash |
| zsh |

Scenario Outline: Sets proper environment variables in shell with weird filenames
Given I am in a git repository
And an empty file named "aa bb"
And an empty file named "bb|cc"
And an empty file named "cc*dd"
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "scmpuff_status"
And I type `echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\n"`
And I type "exit"
Then the output should match /^e1:.*aa bb$/
And the output should match /^e2:.*bb\|cc$/
And the output should match /^e3:.*cc\*dd$/
And the output should match /^e4:$/
Examples:
| shell |
| bash |
| zsh |

Scenario Outline: Clears extra environment variables from before
Given I am in a complex working tree status matching scm_breeze tests
And the scmpuff environment variables have been cleared
Expand Down

0 comments on commit e6a80d3

Please sign in to comment.