Commit graph

415 commits

Author SHA1 Message Date
Avery Pennarun
0e037b8c45 minimal/do: leak fewer variables, especially PREFIX.
Since we use ". filename.do" to run the .do files instead of just
"filename.do", shell local variables end up being inherited by the
subprogram.  Change all the local variables to be all lowercase, to avoid
conflicting with any typical environment variables someone might use.

The particular variable that triggered this was PREFIX (reported by "ulrik"
on the mailing list) and that fixes this, at least.

Arguably we shouldn't be using ".", but using it avoids unnecessary forks,
which is kind of nice.
2011-03-05 19:03:34 -08:00
Avery Pennarun
c1a1f32445 MacOS: "-e filename/." returns true even for non-directories.
This has something to do with resource forks.  So use "-d filename/."
instead, which returns false if filename is not a directory.
2011-03-05 19:03:30 -08:00
Avery Pennarun
97eea66830 redo-sh.do: add 'posh' as another possible shell.
It fails, but who knows, maybe someday it won't.
2011-02-28 22:11:28 -08:00
Avery Pennarun
ee32a965d8 shelltest.od: test that $1/$2/$3 are set correctly in "." scripts.
dash seems to fail this one, and it's not pretty.
2011-02-28 22:07:21 -08:00
Avery Pennarun
32f584cb1c shelltest: detect the ". of empty script" shell problem. 2011-02-28 22:06:57 -08:00
Avery Pennarun
1ed168e79e minimal/do: work around a bug with empty .do files.
If you ". ./filename" and ./filename contains no commands, apparently
ash/dash will give the exit code of the command *before* the ., rather than
defaulting to zero as it supposedly should.  This should work around it in
our .do files at least.

Reported by Tim Allen.
2011-02-28 21:13:55 -08:00
Avery Pennarun
2dde4dbced redo-sh: on Solaris, try /usr/xpg4/bin/sh for a POSIX shell.
Suggested by someone on news.ycombinator.
2011-02-28 05:45:20 -08:00
Avery Pennarun
cfc3f44d64 minimal/do: 'redo-ifchange' with no parameters shouldn't try to build all.
It should just build nothing.  Because sometimes you want to do something
like:
	redo-ifchange $(find -name '*.c')

And the find doesn't return any results.  This is consistent with what real
redo does.

Added a test to confirm that it works.
2011-02-26 18:01:31 -08:00
Avery Pennarun
94c254de77 Rename flush-cache.py to flush-cache, and rearrange the code a bit.
It was working fine, but the style wasn't exactly the way I like it, because
I'm unnecessarily picky. :)

Also, removed the file extension since we should probably learn from the
fact that it's already been rewritten once from one language to another.
Who knows, maybe it will be again someday.
2011-02-23 01:27:41 -08:00
Joseph Garvin
d039aad57b Fix tests when the sqlite3 command line utility isn't installed.
We know the user already has to have python, so use its bindings.
2011-02-23 01:22:04 -08:00
Joseph Garvin
e8790145be Use /usr/bin/env to detect python location
...in case it's installed in a nonstandard location.
2011-02-23 01:21:27 -08:00
Avery Pennarun
0a14db937c README.md: mention the mailing list nearer to the top. 2011-02-22 02:16:37 -08:00
Avery Pennarun
2ef9d69b7b README.md: typo fix for my previous fix. 2011-02-21 15:02:22 -08:00
Avery Pennarun
0ce949fb81 README: a bunch of improvements to answer recent questions.
Inspired by some questions send to me in private email.
2011-02-21 05:11:59 -08:00
Avery Pennarun
a2bce72255 Simplify autodependency examples.
Turns out we don't need sed to process the output of gcc -MD.  We can just
do this:

	read DEPS <filename.deps

The 'read' command in sh actually handles backslashes correctly, so we don't
have to sed them out after all.  And then a simple ${DEPS#*:} removes the
"target:" prefix from the dependency line, and we're done!
2011-02-21 04:00:53 -08:00
Avery Pennarun
ea7057d9b6 redo-ifchange: remove special case for zero arguments.
Not sure why I put there, but special cases aren't worth the hassle.
2011-02-21 03:55:18 -08:00
Avery Pennarun
60b34d81ec vars.do: an improvement on the previous patch.
It would still loop infinitely if a string was "master " (trailing space).
2011-02-17 01:05:52 -08:00
Henry Gebhardt
6508cc0a63 version/vars.do: avoid infinite loop if the tag string is " master"
(ie. with an extra space)
2011-02-15 15:12:53 -08:00
Tim Allen
e27aaf01e7 Make redo read byte-strings from the database.
By default, the database redo uses to store file state returns filenames
as Unicode strings, and if redo tries to run a build-script whose
fully-qualified path contains non-ASCII characters then redo crashes
when trying to promote the path to a Unicode string.

This patch ensures that the database always returns byte-strings, not
Unicode strings. That way, the fully-qualified path and the target name
are both byte-strings and can be joined without issue.

(Fixes a bug reported by Zoran Zaric.)
2011-02-14 18:48:33 -08:00
Avery Pennarun
b43317bb83 md-to-man.do: remove leftover pandoc cruft.
Reported by Jimmy Tang on the mailing list.
2011-01-31 04:12:31 -08:00
Avery Pennarun
e174b09d5f Replace pandoc-based md-to-man conversion with a custom python script.
Hopefully this will appease the people who can't install pandoc on MacOS.
2011-01-29 23:27:23 -08:00
Avery Pennarun
3fdaa7cb0c Merge remote branch 'origin/master'
* origin/master:
  minimal-do: deal with 'clean.do' operations better.
  Add --version flag to `redo`.
2011-01-29 23:22:46 -08:00
Avery Pennarun
304e88022a minimal-do: deal with 'clean.do' operations better.
Sometimes clean.do implementations want to delete our .do_built file and
directory.  If that happens, deal with it quietly, as long as they don't
request any *additional* redo-type operations.
2011-01-28 21:10:04 -08:00
Wayne Larsen
39cfdafd8a Add --version flag to redo.
Something to this effect would be useful, though I'm sure my
install.do changes are not how you'd do it.

(Slightly modified by apenwarr)
2011-01-25 23:14:18 -08:00
Avery Pennarun
71316cc99a shelltest.od: abort correctly if 'cd ~' fails.
It seems 'set -e' doesn't quite work, in some shells, in that case.

Eric Kow wrote:
> I saw this warning, by the way:
> redo      t/shelltest
>   warning: 94
> cd: 271: can't cd to /opt/redo-0.05/t/space
> rmdir: failed to remove pace home dir': No such file or directory
>   warning: 111
2011-01-19 13:54:51 -08:00
Jimmy
b18404aab7 redo-sh.do: add mksh to the list of possible shells. 2011-01-19 13:52:02 -08:00
Avery Pennarun
5ea0cb01f5 version/gitvars: use redo-always if using git commands.
Otherwise we won't rebuild files when the commit id changes.
2011-01-18 00:55:25 -08:00
Avery Pennarun
c077d77285 builder.py: correctly set $3 to include the subdir path.
If we're using a .do file from a parent directory, we should set $3 using
the same path prefix as $1.  We were previously using just the basename,
which mostly works (since we would rename it to $1$2 eventually anyway) but
is not quite right, and you can't safely rename files across filesystems, so
it could theoretically cause problems.

Also improved t/defaults-nested to test for this behaviour.

Reported by Eric Kow.
2011-01-18 00:48:52 -08:00
Avery Pennarun
f3ae4e4e00 vars_init.py: always add .../redo-sh to the PATH, even if it doesn't exist.
Otherwise a fresh 'redo test' in the redo repo won't switch to using
redo-sh/sh after redo-sh.do runs, and the tests aren't accurate.
2011-01-18 00:48:52 -08:00
Avery Pennarun
474f2e71fe shelltest: confirm that 'local' is definitely available.
Supposedly it's not POSIX, but every shell I have seems to support it, so
let's just reject any that don't.  And like magic, anybody using redo can
now count on the 'local' builtin working.
2011-01-18 00:48:51 -08:00
Avery Pennarun
5dbbfd4288 shelltest: die if 'cd ~' can't handle spaces in $HOME.
This fails on ash, dash, and busybox sh (for now).  But it's kind of
important since $HOME often has spaces on Win32.  I hope dash will be fixed
relatively soon.

I downgraded it to a warning since on Unix, this probably isn't a problem.
2011-01-18 00:48:51 -08:00
Jimmy
4a296d676c t/defaults-nested/clean fails on MacOS X.
It seems on OSX find behaves differently (probably from linux):

jtang@exia:~/develop/redo $ make clean
./redo clean
redo  clean
redo    t/clean
redo      t/example/clean
redo      t/curse/clean
redo      t/deps/clean
redo        t/deps/basic/clean
redo        t/deps/dirtest/clean
redo      t/space dir/clean
redo      t/stamp/clean
redo      t/defaults-flat/clean
redo      t/defaults-nested/clean
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *~: No such file or directory
redo      t/defaults-nested/clean: exit code 1
redo    t/clean: exit code 1
redo  clean: exit code 1
make: *** [clean] Error 1

This fixes it for me.
2011-01-18 00:48:51 -08:00
Avery Pennarun
340aad1797 state.Lock: destructor: unlock before closing, not the other way around. 2011-01-18 00:48:51 -08:00
Avery Pennarun
642d60a7c9 state.File.set_static(): barf if we set_static() a nonexistent file.
If that ever happens, we probably got our paths mangled (like in the
previous commit) so we should die right away rather than allow weird things
to happen later.
2011-01-18 00:48:51 -08:00
Avery Pennarun
4c06332ea1 builder.py: we weren't stamping .do files correctly if dodir!='.'.
The result was that t/deps/dirtest was actually failing in some cases.  But
it wasn't failing quite reliably enough, because the failing test was
dirtest/dir1/all, which has the same name as some other 'all' files,
confusing the issue.  Renamed dirtest/dir1/all.do to dirtest/dir1/go.do instead.

Reported by Prakhar Goel and Berke Durak.
2011-01-18 00:48:51 -08:00
Tim Allen
204ac1411d Fix another "==" -> "=" bashism.
I notice it doesn't quite work on my Ubuntu system - if I "cd version"
and run "../redo", I get the following output:

   redo  all
   redo    vars
   redo      gitvars
   [: 24: %H: unexpected operator
   [: 24: %d: unexpected operator
   [: 24: %ci: unexpected operator

...and then a hang.
2011-01-18 00:48:51 -08:00
Avery Pennarun
94b34ea031 Generate redo version codes in Documentation/*.1 automatically.
We have to go through some pretty scary gyrations to extract this
information from git, but it can be done.  This works with both tarballs
generated by 'git archive', or with your local git repo.

(Requested by 'David' on the mailing list.)
2011-01-17 23:01:40 -08:00
Avery Pennarun
897c218f85 redo.md: explain .do file search-parent-dirs feature. 2011-01-16 16:33:22 -08:00
Michael Stone
62fe9a0df5 md-to-man.do: redo-ifcreate on possible paths to pandoc
This way, if you run

  ./redo
  $PKGMGR install pandoc
  ./redo

you'll still wind up with man pages.
2011-01-16 16:21:48 -08:00
Avery Pennarun
a5536fb25b Merge branch 'master' of git://github.com/danvk/redo
* 'master' of git://github.com/danvk/redo:
  fix a few typos in README.md
2011-01-16 16:14:02 -08:00
Avery Pennarun
fdd8b57403 Update README with latest changes.
- minimal/do is bigger now

- minimal/do is public domain

- link to busybox-w32 as a hint to win32 users

- Instead of talking about "Redofile", just explain how to do it with a case
  statement in default.do

- Don't worry about $1 and $2; djb didn't complain :)

- Explain how the search-parent-dirs feature works.  The semantics are now
  that the .do file runs with $PWD set to the dir containing the .do file,
  not the one containing the target.  (This is backwards compatible since
  the two directories always used to be identical.  So now we just change
  the documentation and it's all good.)

- Mention that you can send messages to the mailing list without
  subscribing.
2011-01-15 22:13:50 -08:00
Avery Pennarun
de94c09048 Merge branch 'search-parent-dirs'
* search-parent-dirs:
  minimal/do: support searching parent dirs for .do files.
  Search parent directories for default*.do.
2011-01-15 21:45:59 -08:00
Avery Pennarun
c7f06448c5 minimal/do: support searching parent dirs for .do files.
Now all tests pass again with both redo and minimal/do.
2011-01-15 21:45:25 -08:00
Avery Pennarun
e98696caef Merge branch 'master' into search-parent-dirs
* master:
  Fixed markdown errors in README - code samples now correctly formatted.
  Fix use of config.sh in example
  log.py, minimal/do: don't use ansi colour codes if $TERM is blank or 'dumb'
  Use named constants for terminal control codes.
  redo-sh: keep testing even after finding a 'good' shell.
  redo-sh.do: hide warning output from 'which' in some shells.
  redo-sh.do: wrap long lines.
  Handle .do files that start with "#!/" to specify an explicit interpreter.
  minimal/do: don't print an error on exit if we don't build anything.
  bash completions: also mark 'do' as a completable command.
  bash completions: work correctly when $cur is an empty string.
  bash completions: call redo-targets for a more complete list.
  bash completions: work correctly with subdirs, ie. 'redo t/<tab>'
  Sample bash completion rules for redo targets.
  minimal/do: faster deletion of stamp files.
  minimal/do: delete .tmp files if a build fails.
  minimal/do: use ".did" stamp files instead of empty target files.
  minimal/do: use posix shell features instead of dirname/basename.
  Automatically select a good shell instead of relying on /bin/sh.

Conflicts:
	t/clean.do
2011-01-15 16:00:12 -08:00
Dan Vanderkam
29d0c5b28c fix a few typos in README.md 2011-01-15 09:55:02 -05:00
Miles Gould
4017495c12 Fixed markdown errors in README - code samples now correctly formatted. 2011-01-11 14:02:49 +00:00
Ryan Kuester
6819010401 Fix use of config.sh in example 2011-01-10 22:32:39 -06:00
Avery Pennarun
f6ea1fd76b log.py, minimal/do: don't use ansi colour codes if $TERM is blank or 'dumb'
Apparently emacs sets TERM=dumb in its tty simulator, so even though
isatty() returns true, we shouldn't use colour codes.  (emacs is therefore
lame. But we knew that.)
2011-01-04 14:11:29 -08:00
Tim Allen
cb1512b14b Use named constants for terminal control codes.
(apenwarr slightly changed the minimal/do tty detection.)
2011-01-04 14:10:20 -08:00
Avery Pennarun
eea3f5446a redo-sh: keep testing even after finding a 'good' shell.
Otherwise we miss out on seeing the results from additional tests.
2011-01-02 12:00:37 -08:00