~emersion/mrsh

Move $(LIBS) to end of compile command

Without this change, when I run `make` it fails with this error (edited
for clarity):

```
ld: frontend/readline.o: in function `sigint_handler':
mrsh/frontend/readline.c:33: undefined reference to `rl_on_new_line'
ld: mrsh/frontend/readline.c:34: undefined reference to `rl_replace_line'
ld: mrsh/frontend/readline.c:35: undefined reference to `rl_redisplay'
ld: frontend/readline.o: in function `interactive_init':
ld: mrsh/frontend/readline.c:53: undefined reference to `read_history'
ld: frontend/readline.o: in function `interactive_next':
ld: mrsh/frontend/readline.c:74: undefined reference to `add_history'
ld: mrsh/frontend/readline.c:76: undefined reference to `write_history'
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: mrsh] Error 1
```

It turns out that the placement of `-l` in the command is significant
[1]; it should come after the object files that depend on the library.

> It makes a difference where in the command you write this option; the
> linker searches and processes libraries and object files in the order
> they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after
> file foo.o but before bar.o. If bar.o refers to functions in ‘z’,
> those  functions may not be loaded.

Moving $(LIBS) to the end of the command (right next to -lmrsh) fixes
the error.

Tested using gcc 12.2.0 and clang 15.0.0

[1] https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
readme: drop link to website
readme: update CI badge to use master branch
cd3c3a48 — Chloe Kudryavtsev 3 years ago
Add support for building static executables

This fixes the following issues:
* linked objects do not use LDFLAGS
* pkg-config is not queried appropriately depending on the desired linkage
* there's no way to configure/deconfigure static linking
  (except by setting LDFLAGS, which won't work due to the prior two)

There are many ways of fixing these, but I went for the minimally intrusive approach:
* any linked objects have `$(LDFLAGS)` in front of `$(LIBS)`
* configure has a --static and --dynamic flag
* --static is added to ldflags only if selected
Makefile: Add uninstall rule
280fdf5e — Casey Duncan 3 years ago
Fix crash in set builtin
df5641d1 — Casey Duncan 3 years ago
Extra checks to ensure we don't clobber std fds
Handle weird OUTDIR values in ./configure
Fix segfault when calling `mrsh -o`

* at main.c we call mrsh_process_args from builtins/set.c
* that function calls set function impl. in the same file.
* set function returns early in its switch block commandline arg `-o`
  when called without a long option.
* this might be the desired behaviour, but it skips populating
  state->frame
* the code responsible for that is after the switch statement
* add a jump to handle this case
Initialise arith_nested_parens every word list.
Fix closing of arithmetic double parentheses.

The initial check for "))" does not account for that we might be
still parsing closing parentheses.
Fix arithmetic parsing with parentheses + spaces.

Every time arithmetic_word is called, nested_parens is reset.
Spaces (isblank) causes arithmetic_word to return, so nested_parens
is set to 0 again after every space.
Drop mrsh_limit.h

We don't rely on PATH_MAX anymore.

Closes: https://github.com/emersion/mrsh/issues/167
frontend: don't rely on PATH_MAX for readline history

References: https://github.com/emersion/mrsh/issues/167
builtin/cd: stop using PATH_MAX

References: https://github.com/emersion/mrsh/issues/167
shell: don't rely on PATH_MAX for .profile

References: https://github.com/emersion/mrsh/issues/167
Don't rely on PATH_MAX when calling getcwd

References: https://github.com/emersion/mrsh/issues/167
Make expand_path return allocated memory

Gets rid of one PATH_MAX use.
Define PATH_MAX

According to POSIX, PATH_MAX may or may not be defined.
Let's define it in case it is not set.

Fix https://github.com/emersion/mrsh/issues/143
Replace assert(0) with abort()

This ensures functions reaching the asserts won't return, and avoids
issues with NDEBUG.
Next