Skip to content

Commit

Permalink
Lock dotfiles globbing behind flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Aug 18, 2016
1 parent fc84c42 commit 3cb7471
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Drop it in your `$PATH` with executable rights

## Example output
```
$ git ls
$ git ls -a
1 Staged
12345678901234567890 Not committed
composer.json 5 weeks ago 7748f2e Add me to authors
Expand Down
14 changes: 12 additions & 2 deletions git-ls
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/bin/bash

if [ "$#" -ne 0 ]
dotfiles=0

if [ "$1" = "-a" -o "$1" = "-A" ]
then
shift
dotfiles=1
fi

if [ "$#" -ne 0 ]
then
if [ ! -d "$1" ]
then
>&2 echo "Usage: git ls [directory]"
Expand All @@ -24,7 +31,10 @@ Creset='\033[0m'

file_length="$(ls -A | wc -L)"

shopt -s dotglob
if [ "$dotfiles" -eq 1 ]
then
shopt -s dotglob
fi

for file in *
do
Expand Down

0 comments on commit 3cb7471

Please sign in to comment.