diff --git a/Makefile b/Makefile
index 91049f4..c7f6dc5 100644
--- a/Makefile
+++ b/Makefile
@@ -14,65 +14,76 @@ LDFLAGS = -lpthread
# compiler
CC=g++
# compiler flags
-CXXFLAGS= -I$(IDIR) -Wall -pedantic -std=c++20
+CXXFLAGS= -I$(IDIR) -Wall -std=c++20
ifeq ($(DEBUG),true)
- # debugging flags
- CC=clang++
- CXXFLAGS += -g -pg -D NO_PARSE_CATCH
+ # debugging flags
+ CXXFLAGS += -g -D DEBUG_MODE
+ RODIR = $(ODIR)/debug
else
- # release flags
- CXXFLAGS += -Ofast
+ # release flags
+ CXXFLAGS += -Ofast
+ RODIR = $(ODIR)/release
+endif
+ifeq ($(STATIC),true)
+ # static links
+ LDFLAGS += -l:libztd.a
+else
+ # dynamic links
+ LDFLAGS += -lztd
+endif
+
+
+ifeq ($(PROFILE),true)
+ CXXFLAGS += -pg
endif
ifneq ($(RELEASE), true)
VSUFFIX=-dev-$(SHA_SHORT)
endif
-ifeq ($(STATIC),true)
- # static links
- LDFLAGS += -l:libztd.a
-else
- # dynamic links
- LDFLAGS += -lztd
-endif
-
## END CONFIG ##
+
$(shell ./generate_version.sh)
$(shell ./generate_shellcode.sh)
-$(shell mkdir -p $(ODIR))
+
+$(shell mkdir -p $(RODIR))
$(shell mkdir -p $(BINDIR))
# automatically find .h and .hpp
-DEPS = $(shell find $(IDIR) -type f -regex '.*\.hp?p?' ! -name 'g_version.h' ! -name 'g_shellcode.h')
+DEPS = $(shell find $(IDIR) -type f -regex '.*\.hp?p?')
# automatically find .c and .cpp and make the corresponding .o rule
-OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.cp?p?' | sed 's|\.cpp|.o|g;s|\.c|.o|g;s|^$(SRCDIR)/|$(ODIR)/|g')
+OBJ = $(shell find $(SRCDIR) -type f -regex '.*\.cp?p?' | sed 's|\.cpp|.o|g;s|\.c|.o|g;s|^$(SRCDIR)/|$(RODIR)/|g')
-build: lxsh $(OBJ) $(DEPS)
+build: $(BINDIR)/$(NAME)
-$(ODIR)/%.o: $(SRCDIR)/%.c $(DEPS)
+# specific files for autogenerated headers
+$(OBJDIR)/options.o: $(SRCDIR)/options.cpp $(DEPS) $(IDIR)/g_version.h
$(CC) $(CXXFLAGS) -c -o $@ $<
-$(ODIR)/%.o: $(SRCDIR)/%.cpp $(DEPS)
+$(OBJDIR)/shellcode.o: $(SRCDIR)/shellcode.cpp $(DEPS) $(IDIR)/g_shellcode.h
$(CC) $(CXXFLAGS) -c -o $@ $<
-$(ODIR)/options.o: $(SRCDIR)/options.cpp $(DEPS) $(IDIR)/g_version.h
+$(OBJDIR)/debashify.o: $(SRCDIR)/debashify.cpp $(DEPS) $(IDIR)/g_shellcode.h
$(CC) $(CXXFLAGS) -c -o $@ $<
-$(ODIR)/shellcode.o: $(SRCDIR)/shellcode.cpp $(DEPS) $(IDIR)/g_shellcode.h
+# generic files
+
+$(RODIR)/%.o: $(SRCDIR)/%.c $(DEPS)
$(CC) $(CXXFLAGS) -c -o $@ $<
-$(ODIR)/debashify.o: $(SRCDIR)/debashify.cpp $(DEPS) $(IDIR)/g_shellcode.h
+$(RODIR)/%.o: $(SRCDIR)/%.cpp $(DEPS)
$(CC) $(CXXFLAGS) -c -o $@ $<
-lxsh: $(OBJ)
+
+$(BINDIR)/$(NAME): $(OBJ)
$(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
test: $(BINDIR)/$(NAME)
$(BINDIR)/$(NAME)
clean:
- rm $(ODIR)/*.o gmon.out
+ rm $(ODIR)/*/*.o
clear:
rm $(BINDIR)/$(NAME)
diff --git a/README.md b/README.md
index e0ded7b..970ce19 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Extended shell linker for linking, processing and minifying shell code
### zpkg
-Available from the `zpkg` repository:
+Available from the [zpkg](https://github.com/zawwz/zpkg) repository:
```shell
wget -qO- https://zpkg.zawz.net/install.sh | sh
zpkg install lxsh
@@ -20,7 +20,7 @@ Download the `lxsh.tar.gz` archive, extract it,
and move the `lxsh` binary in a PATH folder (`/usr/local/bin` is the recommended).
```shell
-wget https://github.com/zawwz/lxsh/releases/download/v1.1.0/lxsh.tar.gz
+wget https://github.com/zawwz/lxsh/releases/download/v1.2.0/lxsh-linux-amd64.tar.gz
tar -xvf lxsh.tar.gz
sudo mv lxsh /usr/local/bin
```
@@ -122,6 +122,23 @@ these features will continue working with undesired behavior.
Array argument with `[@]` does not expand into the desired multiple arguments.
+## Extension commands
+
+If you use the `#!/usr/bin/lxsh` shebang, you can use special lxsh-defined commands.
+To list such commands, see `lxsh --help-extend-fcts`
+
+## String processors
+
+You can use prefixes in singlequote strings to apply processing to the string contents.
+To use string processors, prefix the string content with a line in the form of `#`.
+Example:
+```shell
+sh -c '#LXSH_PARSE_MINIFY
+printf "%s\n" "Hello world!"'
+```
+
+As of now only the processor `LXSH_PARSE_MINIFY` is implemented, but more may come later
+
## Other features
### Output generated code
@@ -154,7 +171,7 @@ Depends on [ztd](https://github.com/zawwz/ztd)
## Building
-Use `make -j13` to build.
+Use `make -j` to build.
You can use environment variables to alter some aspects:
- DEBUG: when set to `true` will generate a debug binary with profiling
- RELEASE: when set to `true`, the version string will be generated for release format
diff --git a/include/debashify.hpp b/include/debashify.hpp
index 8c56b16..7fb96d0 100644
--- a/include/debashify.hpp
+++ b/include/debashify.hpp
@@ -6,13 +6,13 @@
#include