-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EXCLUDES not working as expected #11
Comments
The excludes pattern is Your first example says to match "config/system" in any source. The files "config/systemd/user/..." do not match this since the slash makes them full-path checks. Your second examples both say to match "systemd" in any source. Since this is a basename match, it filters out "config/systemd/*" and "systemd". Your third example says to match "systemd" and "*systemd" both in the "config" source. This won't work because your source is ".dotfiles", not "config". I would try this:
Interestingly, this is the exact thing you stated in English, but the one permutation you didn't attempt in code :) |
I'm pretty sure I tried that O.o, but oh well. Everything can happen. I'm gonna test it asap. |
I actually test it and doesn't work. It just ignore that particular EXCLUDE directive:
With debug on:
|
The problem is in I tried changing it to pass the path:
but then it broke for the case when you don't pass it a glob (in the example you give, it breaks if you pass While working on this I discovered that the glob can get resolved too easily, and e.g. @pbrisbin you're a sh quoting expert. Any advice here? (I just found myself thinking, "if I converted all the strings to binary my life would be easier," and then realized just how crazy that sounds.) |
I'm not sure this is a quoting issue. It's true that the potential globs should be quoted while being passed around and can't be quoted in the What about the following logic for
Would that cover all cases? |
Yeah, @pbrisbin , that might work. I'd like someone besides me to take a crack at this; I'm having trouble thinking of a great solution. |
I don't know how to pass a glob around without it being expanded:
|
You just have to quote it. $ touch foo bar baz
$ for g in 'f*' 'b*'; do # strings
> ls "$g" # still string
> ls $g # expandable glob
> done
ls: cannot access f*: No such file or directory
foo
ls: cannot access b*: No such file or directory
bar baz |
OK, that resolves that a bit, but even when I quote things lsrc(1) expands them:
|
It's always quoting. I'm going to coin Pat's theorem:
And the corollary:
here: for exclude in $excludes; do # globs expand
# ... There may be a |
How can I iterate over a space-separated list of globs? Where do I put quotes to make this happen? |
I've opened #54. It doesn't fix this problem at all, but it's a decent start. |
(Haven't looked at it, stuck on train but...) How about concatting the patterns with "|" at arg parsing, then doing a This makes the full-path-vs-basename problem harder though :/ BTW,
|
If we have to keep it in a space separated list, something like this may work: matches_patterns() {
local file="$1" patterns="$2"
echo "$patterns" | sed 's/ /\n/g' | while read pattern; do
# treat as glob, file, base, etc here...
case "$file" of
$pattern) return 0 ;;
esac
done
return 1
} |
Yeah,
|
I've opened #55, too, for discussion on that topic. |
Until we can get a handle on globbing, we cannot close #11. That bug is the last remaining ticket blocking the 1.2.1 release. However, it may involve a larger modification than a patch release should. Documenting allows us to make the release while working on the bug for the next release. http://1389blog.com/pix/thats-a-feature-not-a-bug.jpg
Until we can get a handle on globbing, we cannot close #11. That bug is the last remaining ticket blocking the 1.2.1 release. However, it may involve a larger modification than a patch release should. Documenting allows us to make the release while working on the bug for the next release. http://1389blog.com/pix/thats-a-feature-not-a-bug.jpg
No. It's fine by me. Anyway, I believe for most use cases, the actual implementation works fine. The edge cases or when you want to specify a particular file inside a subdirectory it's when things go eerie. I know the idea is to keep this project as POSIX as possible, but it seems a POSIX compatible shell wasn't built for this task. Why not using perl, sed or awk to accomplish this? |
The idea is to keep the project as able-to-run-on-any-machine-out-of-the-box as possible. My targets are (in order) FreeBSD, GNU, OS X, Solaris. This leaves us with POSIX sh and POSIX awk (sed won't suffice). That said, I'd be willing to entertain the idea of a binary+VM packaged together. |
And what about perl? I guess my Archlinux distro falls in the GNU category right? |
Perl is far from standard. FreeBSD is the first example that comes to mind. The only Linux distros I know of that are not GNU are Android, Busybox, and UNG/Linux. |
This was closed because GitHub is clever. |
Short of the Haskell rewrite: we could apply the globs after-the-fact in lsrc(1). So collect all files, then go through the list and exclude any that match the appropriate globs. |
This is based on #11 - Handle an exclude glob with a path. - Handle an exclude glob without a path. I am unsure whether we want to maintain compatibility for exclude globs without a path.
Captured in a test on the |
Otherwise we can't exclude `packages/*`.... See thoughtbot/rcm#11 Seems to be ok to share userId: atom/metrics#18
This is based on #11 - Handle an exclude glob with a path. - Handle an exclude glob without a path. I am unsure whether we want to maintain compatibility for exclude globs without a path.
This might be fixed by #192. |
I have the following files in my
~/.dotfiles
directory:I only want to exclude
config/systemd/*
, so I've tried the following:Following the instructions for the lsrc man page, I followed the idea of the thoughbot-dotfiles example:
Same thing... am I misunderstanding how it works?
The text was updated successfully, but these errors were encountered: