From ec4182fcf1541d2b3fc3fc60740682127e11949d Mon Sep 17 00:00:00 2001 From: dokaptur Date: Fri, 23 Jan 2015 17:35:54 +0100 Subject: [PATCH] stdbuf - install multicall --- Makefile | 25 +++++++++++++++---------- src/stdbuf/stdbuf.rs | 13 ++++++------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index bc1da52e6..0d1c44bea 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,15 @@ ENABLE_LTO ?= n ENABLE_STRIP ?= n # Binaries -RUSTC ?= rustc -CARGO ?= cargo -CC ?= gcc -RM := rm +RUSTC ?= rustc +CARGO ?= cargo +CC ?= gcc +RM := rm # Install directories -PREFIX ?= /usr/local -BINDIR ?= /bin -LIBDIR ?= /lib +PREFIX ?= /usr/local +BINDIR ?= /bin +LIBDIR ?= /lib # This won't support any directory with spaces in its name, but you can just # make a symlink without spaces that points to the directory. @@ -143,16 +143,16 @@ INSTALLEES := \ SYSTEM := $(shell uname) DYLIB_EXT := ifeq ($(SYSTEM),Linux) - DYLIB_EXT := so + DYLIB_EXT := .so endif ifeq ($(SYSTEM),Darwin) - DYLIB_EXT := dylib + DYLIB_EXT := .dylib endif # Libaries to install LIBS := ifneq (,$(findstring stdbuf, $(INSTALLEES))) -LIBS += libstdbuf.$(DYLIB_EXT) +LIBS += libstdbuf$(DYLIB_EXT) endif # Programs with usable tests @@ -319,6 +319,10 @@ install-multicall: $(BUILDDIR)/uutils for prog in $(INSTALLEES); do \ ln -s $(PROG_PREFIX)uutils $$prog; \ done + mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR) + for lib in $(LIBS); do \ + install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \ + done uninstall: rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) @@ -326,6 +330,7 @@ uninstall: uninstall-multicall: rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils) + rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS)) # Test under the busybox testsuite $(BUILDDIR)/busybox: $(BUILDDIR)/uutils diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 3c7f8e8aa..100cc2641 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) { #[cfg(target_os = "macos")] fn preload_strings() -> (&'static str, &'static str) { - ("DYLD_INSERT_LIBRARIES", ".dyl") + ("DYLD_INSERT_LIBRARIES", ".dylib") } #[cfg(not(any(target_os = "linux", target_os = "macos")))] @@ -216,7 +216,7 @@ pub fn uumain(args: Vec) -> isize { let mut options = ProgramOptions {stdin: BufferType::Default, stdout: BufferType::Default, stderr: BufferType::Default}; let mut command_idx = -1; for i in range_inclusive(1, args.len()) { - match parse_options(args.slice(1, i), &mut options, &optgrps) { + match parse_options(&args[1 .. i], &mut options, &optgrps) { Ok(OkMsg::Buffering) => { command_idx = i - 1; break; @@ -239,14 +239,13 @@ pub fn uumain(args: Vec) -> isize { let ref command_name = args[command_idx]; let mut command = Command::new(command_name); let (preload_env, libstdbuf) = get_preload_env(); - command.args(args.slice_from(command_idx+1)).env(preload_env.as_slice(), libstdbuf.as_slice()); + command.args(&args[command_idx + 1 ..]).env(preload_env.as_slice(), libstdbuf.as_slice()); command.stdin(StdioContainer::InheritFd(0)).stdout(StdioContainer::InheritFd(1)).stderr(StdioContainer::InheritFd(2)); set_command_env(&mut command, "_STDBUF_I", options.stdin); set_command_env(&mut command, "_STDBUF_O", options.stdout); set_command_env(&mut command, "_STDBUF_E", options.stderr); - match command.spawn() { - Ok(_) => {}, - Err(e) => crash!(1, "failed to execute process: {}", e), - }; + if let Err(e) = command.spawn() { + crash!(1, "failed to execute process: {}", e); + } 0 }