(command.CommandList children: [ (command.FuncDef name: usage body: (command.BraceGroup children: [ (command.Sentence child: (command.Simple words: [ {(echo)} { (DQ (word_part.CommandSub left_token: <Left_DollarParen '$('> command_list: (command.CommandList children: [(C {(basename)} {($ VSub_Number '$0')})] ) ) ( ' [-h] [-w <print-width>] -d <path> -f <x.y.z> -- upgrade syntax from version specified by -f to the latest version installed in the system\n' ) ('\n') ('where:\n') (' -h: show this text\n') (' -w <print-width=90>: change print-width of upgraded files\n') (' -d <path>: source code directory to be upgraded\n') (' -b <path>: path for backup directory\n') (' -f <x.y.z>: current version of the source file to be upgraded\n') (' ') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) terminator: <Op_Semi ';'> ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:REASON_GIT) op: Equal rhs: {(DQ ('git@github.com:facebook/Reason.git'))} ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:MERLINEXTEND_GIT) op: Equal rhs: {(DQ ('git@github.com:def-lkb/merlin-extend.git'))} ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:OPAM_BIN) op: Equal rhs: { (word_part.CommandSub left_token: <Left_DollarParen '$('> command_list: (command.CommandList children: [(C {(opam)} {(config)} {(KW_Var var)} {(bin)})] ) ) } ) ] ) (command.Assignment pairs: [(assign_pair lhs:(lhs_expr.LhsName name:PRINTWIDTH) op:Equal rhs:{(90)})] ) (command.FuncDef name: install_refmt body: (command.BraceGroup children: [ (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:VERSION) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: BoolUnary_f child: {($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION') } ) ) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} { (DQ (refmt-) ($ VSub_DollarName '$VERSION') (' already exists at ') ($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION') (', skipping installation') ) } ) (command.ControlFlow token: <ControlFlow_Return return> arg_word: {(0)} ) ] ) ] ) (C {(read)} {(-p)} { (DQ (refmt-) ($ VSub_DollarName '$VERSION') (' is needed but not found at ') ($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION') (', do you want me to install it? [Y/n]:') ) } {(-n)} {(1)} {(-r)} ) (command.If arms: [ (if_arm cond: [ (command.DBracket expr: (bool_expr.LogicalNot child: (bool_expr.Binary op_id: BoolBinary_EqualTilde left: {($ VSub_DollarName '$REPLY')} right: {(Lit_Other '^') (Lit_Other '[') (Yy) (Lit_Other ']') (Lit_Other '$')} ) ) ) ] action: [(command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})] ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:BUILD_DIR) op: Equal rhs: { (word_part.CommandSub left_token: <Left_DollarParen '$('> command_list: (command.CommandList children: [(C {(mktemp)} {(-d)} {(-t)} {(reason_upgrade.XXXXXXXX)})] ) ) } ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:OPAM_DIR) op: Equal rhs: {(DQ ($ VSub_DollarName '$BUILD_DIR') (/opam))} ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:REASON_DIR) op: Equal rhs: {(DQ ($ VSub_DollarName '$BUILD_DIR') (/reason))} ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:MERLINEXTEND_DIR) op: Equal rhs: {(DQ ($ VSub_DollarName '$BUILD_DIR') (/merlin-extend))} ) ] ) (C {(echo)} {(DQ ('Initing opam at ') ($ VSub_DollarName '$OPAM_DIR'))}) (C {(opam)} {(init)} {(--quiet)} {(-n)} {(--root)} {($ VSub_DollarName '$OPAM_DIR')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: BoolBinary_ne left: {($ VSub_QMark '$?')} right: {(0)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't init opam at ") ($ VSub_DollarName '$OPAM_DIR') (', exiting')) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ] ) (command.Sentence child: (C {(git)} {(clone)} {($ VSub_DollarName '$REASON_GIT')} {(--branch)} {($ VSub_DollarName '$VERSION')} {(--depth)} {(1)} {($ VSub_DollarName '$REASON_DIR')} ) terminator: <Op_Semi ';'> ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: BoolBinary_ne left: {($ VSub_QMark '$?')} right: {(0)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't clone reason from ") ($ VSub_DollarName '$REASON_GIT') (' to ') ($ VSub_DollarName '$REASON_DIR') (', exiting') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ] ) (command.Sentence child: (C {(git)} {(clone)} {($ VSub_DollarName '$MERLINEXTEND_GIT')} {(--depth)} {(1)} {($ VSub_DollarName '$MERLINEXTEND_DIR')} ) terminator: <Op_Semi ';'> ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: BoolBinary_ne left: {($ VSub_QMark '$?')} right: {(0)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't clone merlin-extend from ") ($ VSub_DollarName '$MERLINEXTEND_GIT') (' to ') ($ VSub_DollarName '$MERLINEXTEND_DIR') (', exiting') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ] ) (C {(opam)} {(pin)} {(add)} {($ VSub_DollarName '$MERLINEXTEND_DIR')} {(--root)} {($ VSub_DollarName '$OPAM_DIR')} {(-y)} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: BoolBinary_ne left: {($ VSub_QMark '$?')} right: {(0)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ VSub_DollarName '$MERLINEXTEND_DIR') (' into ') ($ VSub_DollarName '$OPAM_DIR') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ] ) (C {(opam)} {(pin)} {(add)} {($ VSub_DollarName '$REASON_DIR')} {(--root)} {($ VSub_DollarName '$OPAM_DIR')} {(-y)} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: BoolBinary_ne left: {($ VSub_QMark '$?')} right: {(0)} ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ VSub_DollarName '$REASON_DIR') (' into ') ($ VSub_DollarName '$OPAM_DIR') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (command.Sentence child: (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] ) ] ) (C {(echo)} { (DQ ('Installing refmt-') ($ VSub_DollarName '$VERSION') (' to OPAM_BIN/refmt-') ($ VSub_DollarName '$VERSION') ) } ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:OPAM_BIN_SANDBOX) op: Equal rhs: { (word_part.CommandSub left_token: <Left_DollarParen '$('> command_list: (command.CommandList children: [ (C {(opam)} {(config)} {(KW_Var var)} {(bin)} {(--root)} {($ VSub_DollarName '$OPAM_DIR')} ) ] ) ) } ) ] ) (C {(cp)} {($ VSub_DollarName '$OPAM_BIN_SANDBOX') (/refmt)} {($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION')} ) (C {(echo)} {(DQ ('Removing sandbox ') ($ VSub_DollarName '$OPAM_BIN_SANDBOX'))}) (C {(rm)} {(-rf)} {($ VSub_DollarName '$OPAM_BIN_SANDBOX')}) ] ) ) (command.WhileUntil keyword: <KW_While while> cond: [ (command.Sentence child: (C {(getopts)} {(SQ <':hf:d:w:b:'>)} {(option)}) terminator: <Op_Semi ';'> ) ] body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_DollarName '$option'))} arms: [ (case_arm pat_list:[{(h)}] action:[(C {(usage)})]) (case_arm pat_list: [{(d)}] action: [ (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:DIR) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} ) ] ) ] ) (case_arm pat_list: [{(b)}] action: [ (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:BACKUP_DIR) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} ) ] ) ] ) (case_arm pat_list: [{(f)}] action: [ (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FROM) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} ) ] ) ] ) (case_arm pat_list: [{(w)}] action: [ (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:PRINTWIDTH) op: Equal rhs: {($ VSub_DollarName '$OPTARG')} ) ] ) ] ) ] ) ] ) ) (C {(shift)} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Arith_Minus left: (arith_expr.VarRef token:<Lit_ArithVarLike OPTIND>) right: (arith_expr.ArithWord w:{(Lit_Digits 1)}) ) ) } ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:BoolUnary_z child:{($ VSub_DollarName '$DIR')}) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('No -d provided'))}] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] ) ] ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:DIR) op: Equal rhs: { (word_part.CommandSub left_token: <Left_Backtick '`'> command_list: (command.CommandList children: [ (command.Sentence child: (C {(cd)} {(DQ ($ VSub_DollarName '$DIR'))}) terminator: <Op_Semi ';'> ) (C {(pwd)}) ] ) ) } ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:BoolUnary_z child:{($ VSub_DollarName '$FROM')}) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('No -f <from_version> provided'))}] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalNot child: (bool_expr.Binary op_id: BoolBinary_EqualTilde left: {($ VSub_DollarName '$FROM')} right: {(Lit_Other '^') (Lit_Other '(') (Lit_Other '[') (0-9) (Lit_Other ']') (Lit_RegexMeta '\\.') (Lit_Other '[') (0-9) (Lit_Other ']') (Lit_RegexMeta '\\.') (Lit_Other '[') (0-9) (Lit_Other ']') (Lit_Other ')') (Lit_Other '$') } ) ) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('version provided by -f should be in the form of x.y.z'))}] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] ) ] ) (C {(install_refmt)} {($ VSub_DollarName '$FROM')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:BoolUnary_z child:{($ VSub_DollarName '$BACKUP_DIR')}) ) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} { (DQ ('No -b <backup_dir> specified, default to use ') ($ VSub_DollarName '$DIR') (.backup) ) } ) (command.Assignment pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:BACKUP_DIR) op: Equal rhs: {($ VSub_DollarName '$DIR') (.backup)} ) ] ) ] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:BoolUnary_d child:{($ VSub_DollarName '$BACKUP_DIR')}) ) terminator: <Op_Semi ';'> ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ('Fail to backup: ') ($ VSub_DollarName '$BACKUP_DIR') (' already exists, exiting') ) } ] redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] ) ] ) (C {(echo)} {(DQ ('Backing up at ') ($ VSub_DollarName '$BACKUP_DIR'))}) (C {(cp)} {(-af)} {($ VSub_DollarName '$DIR')} {($ VSub_DollarName '$BACKUP_DIR')}) (command.Pipeline children: [ (C {(find)} {($ VSub_DollarName '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.re'))}) (command.WhileUntil keyword: <KW_While while> cond: [(command.Sentence child:(C {(read)} {(file)}) terminator:<Op_Semi ';'>)] body: (command.DoGroup children: [ (C {(set)} {(-x)}) (command.Pipeline children: [ (C {($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION')} {(-print)} {(binary_reason)} {($ VSub_DollarName '$file')} ) (command.Simple words: [ {($ VSub_DollarName '$OPAM_BIN') (/refmt)} {(-print-width)} {($ VSub_DollarName '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-is-interface-pp)} {(false)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {($ VSub_DollarName '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ VSub_DollarName '$file') (.new)} {($ VSub_DollarName '$file')}) (C {(set)} {(Lit_Other '+') (x)}) ] ) ) ] negated: F ) (C {(set)} {(-x)}) (command.Pipeline children: [ (C {(find)} {($ VSub_DollarName '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.rei'))}) (command.WhileUntil keyword: <KW_While while> cond: [(command.Sentence child:(C {(read)} {(file)}) terminator:<Op_Semi ';'>)] body: (command.DoGroup children: [ (command.Pipeline children: [ (C {($ VSub_DollarName '$OPAM_BIN') (/refmt-) ($ VSub_DollarName '$VERSION')} {(-is-interface-pp)} {(true)} {(-print)} {(binary_reason)} {($ VSub_DollarName '$file')} ) (command.Simple words: [ {($ VSub_DollarName '$OPAM_BIN') (/refmt)} {(-is-interface-pp)} {(true)} {(-print-width)} {($ VSub_DollarName '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {($ VSub_DollarName '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ VSub_DollarName '$file') (.new)} {($ VSub_DollarName '$file')}) ] ) ) ] negated: F ) (C {(set)} {(Lit_Other '+') (x)}) (C {(echo)} {(DQ ('Done. Original files are backed up at ') ($ VSub_DollarName '$BACKUP_DIR'))}) ] )