blob: d2e37249a7a06db702b0389fe49076db8cf182a8 [file] [log] [blame]
From 504e2c48dd2ae889f5b76efcde5da18580dcbab3 Mon Sep 17 00:00:00 2001
From: Junjie Mao <eternal.n08@gmail.com>
Date: Thu, 2 Apr 2015 19:18:55 +0800
Subject: [PATCH] Fix the 'List.hd []' exception
get_output may return [] if the cmd prints nothing, leading get_output1
to fail due to a 'List.hd []'. 'gcc -print-sysroot' is such a case.
Signed-off-by: Junjie Mao <eternal.n08@gmail.com>
---
reloc.ml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/reloc.ml b/reloc.ml
index e175802..5f92e10 100644
--- a/reloc.ml
+++ b/reloc.ml
@@ -85,7 +85,9 @@ let get_output ?(use_bash = false) ?(accept_error=false) cmd =
r
let get_output1 ?use_bash cmd =
- List.hd (get_output ?use_bash cmd)
+ match (get_output ?use_bash cmd) with
+ | [] -> ""
+ | h :: t -> h
(* Preparing command line *)
--
2.3.4