aboutsummaryrefslogtreecommitdiffstats
path: root/testing/reason/rtop.sh.patch
blob: 73682fd4ce4e4ace50426c12e59921a5a6d61f3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--- a/src/rtop/rtop.sh
+++ b/src/rtop/rtop.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 # Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
 
 
@@ -13,15 +13,26 @@
 #    require's reason, so that reason is required after .ocamlinit is
 #    parsed in standard syntax.
 
-touch $HOME/.utoprc
-touch $HOME/.utop-history
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+# Enable pipefail if supported.
+if ( set -o pipefail 2>/dev/null ); then
+	set -o pipefail
+fi
 
+touch "$HOME"/.utoprc
+touch "$HOME"/.utop-history
+
 # intercept the -stdin flag of utop, and preprocess the code into reason code
 # before forwarding it. Afaik currently there's no better way of intercepting
 # the code after urtop receives code from stdin and before it processes it
-if [[ $@ =~ "stdin" ]]; then
-    refmt --parse re --print ml --interface false | utop-full $@
+stdin=no
+for arg in "$@"; do
+	case "$arg" in
+		-stdin) stdin=yes; break;;
+	esac
+done
+
+if [ "$stdin" = yes ]; then
+	refmt --parse re --print ml --interface false | utop-full "$@"
 else
-    utop-full -init $DIR/rtop_init.ml $@ -I $HOME -safe-string
+	utop-full -init /usr/share/reason-rtop/rtop_init.ml "$@" -I "$HOME" -safe-string
 fi