(command.CommandList children: [ (command.ShFunction name: usage body: (command.BraceGroup children: [ (command.Sentence child: (command.Simple words: [ {<echo>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> command_list: (command.CommandList children: [(C {<basename>} {($ Id.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:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) terminator: <Id.Op_Semi _> ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:REASON_GIT) op: assign_op.Equal rhs: {(DQ <'git@github.com:facebook/Reason.git'>)} spids: [44] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:MERLINEXTEND_GIT) op: assign_op.Equal rhs: {(DQ <'git@github.com:def-lkb/merlin-extend.git'>)} spids: [49] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_BIN) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> command_list: (command.CommandList children: [(C {<opam>} {<config>} {<Id.KW_Var var>} {<bin>})] ) ) } spids: [55] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PRINTWIDTH) op: assign_op.Equal rhs: {<90>} spids: [67] ) ] ) (command.ShFunction name: install_refmt body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VERSION) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [78] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_f child: {($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.VSub_DollarName '$VERSION') } ) ) terminator: <Id.Op_Semi _> ) ] action: [ (C {<echo>} { (DQ <refmt-> ($ Id.VSub_DollarName '$VERSION') <' already exists at '> ($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.VSub_DollarName '$VERSION') <', skipping installation'> ) } ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<0>} ) ] spids: [82 96] ) ] ) (C {<read>} {<-p>} { (DQ <refmt-> ($ Id.VSub_DollarName '$VERSION') <' is needed but not found at '> ($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.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: Id.BoolBinary_EqualTilde left: {($ Id.VSub_DollarName '$REPLY')} right: {<Id.Lit_Other '^'> <Id.Lit_Other '['> <Yy> <Id.Lit_Other ']'> <Id.Lit_Other '$'> } ) ) ) ] action: [(command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})] spids: [141 160] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BUILD_DIR) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> command_list: (command.CommandList children: [(C {<mktemp>} {<-d>} {<-t>} {<reason_upgrade.XXXXXXXX>})] ) ) } spids: [171] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') </opam>)} spids: [183] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:REASON_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') </reason>)} spids: [190] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:MERLINEXTEND_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') </merlin-extend>)} spids: [197] ) ] ) (C {<echo>} {(DQ <'Initing opam at '> ($ Id.VSub_DollarName '$OPAM_DIR'))}) (C {<opam>} {<init>} {<--quiet>} {<-n>} {<--root>} {($ Id.VSub_DollarName '$OPAM_DIR')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <"Couldn't init opam at "> ($ Id.VSub_DollarName '$OPAM_DIR') <', exiting'> ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] spids: [225 238] ) ] ) (command.Sentence child: (C {<git>} {<clone>} {($ Id.VSub_DollarName '$REASON_GIT')} {<--branch>} {($ Id.VSub_DollarName '$VERSION')} {<--depth>} {<1>} {($ Id.VSub_DollarName '$REASON_DIR')} ) terminator: <Id.Op_Semi _> ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <"Couldn't clone reason from "> ($ Id.VSub_DollarName '$REASON_GIT') <' to '> ($ Id.VSub_DollarName '$REASON_DIR') <', exiting'> ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] spids: [280 293] ) ] ) (command.Sentence child: (C {<git>} {<clone>} {($ Id.VSub_DollarName '$MERLINEXTEND_GIT')} {<--depth>} {<1>} {($ Id.VSub_DollarName '$MERLINEXTEND_DIR')} ) terminator: <Id.Op_Semi _> ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <"Couldn't clone merlin-extend from "> ($ Id.VSub_DollarName '$MERLINEXTEND_GIT') <' to '> ($ Id.VSub_DollarName '$MERLINEXTEND_DIR') <', exiting'> ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] spids: [334 347] ) ] ) (C {<opam>} {<pin>} {<add>} {($ Id.VSub_DollarName '$MERLINEXTEND_DIR')} {<--root>} {($ Id.VSub_DollarName '$OPAM_DIR')} {<-y>} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <"Couldn't opam pin "> ($ Id.VSub_DollarName '$MERLINEXTEND_DIR') <' into '> ($ Id.VSub_DollarName '$OPAM_DIR') ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] spids: [388 401] ) ] ) (C {<opam>} {<pin>} {<add>} {($ Id.VSub_DollarName '$REASON_DIR')} {<--root>} {($ Id.VSub_DollarName '$OPAM_DIR')} {<-y>} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {<0>} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <"Couldn't opam pin "> ($ Id.VSub_DollarName '$REASON_DIR') <' into '> ($ Id.VSub_DollarName '$OPAM_DIR') ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (command.Sentence child: (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>}) terminator: <Id.Op_Semi _> ) ] spids: [442 455] ) ] ) (C {<echo>} { (DQ <'Installing refmt-'> ($ Id.VSub_DollarName '$VERSION') <' to OPAM_BIN/refmt-'> ($ Id.VSub_DollarName '$VERSION') ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_BIN_SANDBOX) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> command_list: (command.CommandList children: [ (C {<opam>} {<config>} {<Id.KW_Var var>} {<bin>} {<--root>} {($ Id.VSub_DollarName '$OPAM_DIR')} ) ] ) ) } spids: [492] ) ] ) (C {<cp>} {($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX') </refmt>} {($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.VSub_DollarName '$VERSION')} ) (C {<echo>} {(DQ <'Removing sandbox '> ($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX'))}) (C {<rm>} {<-rf>} {($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX')}) ] ) ) (command.WhileUntil keyword: <Id.KW_While while> cond: [ (command.Sentence child: (C {<getopts>} {(SQ <':hf:d:w:b:'>)} {<option>}) terminator: <Id.Op_Semi _> ) ] body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$option'))} arms: [ (case_arm pat_list: [{<h>}] action: [(C {<usage>})] spids: [561 562 567 -1] ) (case_arm pat_list: [{<d>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [573] ) ] ) ] spids: [570 571 577 -1] ) (case_arm pat_list: [{<b>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BACKUP_DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [583] ) ] ) ] spids: [580 581 587 -1] ) (case_arm pat_list: [{<f>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FROM) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [593] ) ] ) ] spids: [590 591 597 -1] ) (case_arm pat_list: [{<w>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PRINTWIDTH) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [603] ) ] ) ] spids: [600 601 607 -1] ) ] ) ] ) ) (C {<shift>} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Minus left: (arith_expr.VarRef token:<Id.Lit_ArithVarLike OPTIND>) right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>}) ) ) } ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:Id.BoolUnary_z child:{($ Id.VSub_DollarName '$DIR')}) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [{<echo>} {(DQ <'No -d provided'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (C {<usage>}) ] spids: [626 637] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:DIR) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_Backtick '`'> command_list: (command.CommandList children: [ (command.Sentence child: (C {<cd>} {(DQ ($ Id.VSub_DollarName '$DIR'))}) terminator: <Id.Op_Semi _> ) (C {<pwd>}) ] ) ) } spids: [655] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:Id.BoolUnary_z child:{($ Id.VSub_DollarName '$FROM')}) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [{<echo>} {(DQ <'No -f <from_version> provided'>)}] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (C {<usage>}) ] spids: [670 681] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalNot child: (bool_expr.Binary op_id: Id.BoolBinary_EqualTilde left: {($ Id.VSub_DollarName '$FROM')} right: {<Id.Lit_Other '^'> <Id.Lit_Other '('> <Id.Lit_Other '['> <0-9> <Id.Lit_Other ']'> <Id.Lit_RegexMeta '\\.'> <Id.Lit_Other '['> <0-9> <Id.Lit_Other ']'> <Id.Lit_RegexMeta '\\.'> <Id.Lit_Other '['> <0-9> <Id.Lit_Other ']'> <Id.Lit_Other ')'> <Id.Lit_Other '$'> } ) ) ) terminator: <Id.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:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (C {<usage>}) ] spids: [699 728] ) ] ) (C {<install_refmt>} {($ Id.VSub_DollarName '$FROM')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_z child: {($ Id.VSub_DollarName '$BACKUP_DIR')} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (C {<echo>} { (DQ <'No -b <backup_dir> specified, default to use '> ($ Id.VSub_DollarName '$DIR') <.backup> ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BACKUP_DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$DIR') <.backup>} spids: [774] ) ] ) ] spids: [751 762] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_d child: {($ Id.VSub_DollarName '$BACKUP_DIR')} ) ) terminator: <Id.Op_Semi _> ) ] action: [ (command.Simple words: [ {<echo>} { (DQ <'Fail to backup: '> ($ Id.VSub_DollarName '$BACKUP_DIR') <' already exists, exiting'> ) } ] redirects: [(redir.Redir op:<Id.Redir_GreatAnd '1>&'> fd:1 arg_word:{<2>})] ) (C {<usage>}) ] spids: [781 792] ) ] ) (C {<echo>} {(DQ <'Backing up at '> ($ Id.VSub_DollarName '$BACKUP_DIR'))}) (C {<cp>} {<-af>} {($ Id.VSub_DollarName '$DIR')} {($ Id.VSub_DollarName '$BACKUP_DIR')}) (command.Pipeline children: [ (C {<find>} {($ Id.VSub_DollarName '$DIR')} {<-type>} {<f>} {<-name>} {(DQ <'*.re'>)}) (command.WhileUntil keyword: <Id.KW_While while> cond: [(command.Sentence child:(C {<read>} {<file>}) terminator:<Id.Op_Semi _>)] body: (command.DoGroup children: [ (C {<Id.KW_Set set>} {<-x>}) (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.VSub_DollarName '$VERSION')} {<-print>} {<binary_reason>} {($ Id.VSub_DollarName '$file')} ) (command.Simple words: [ {($ Id.VSub_DollarName '$OPAM_BIN') </refmt>} {<-print-width>} {($ Id.VSub_DollarName '$PRINTWIDTH')} {<-use-stdin>} {<true>} {<-is-interface-pp>} {<false>} {<-parse>} {<binary_reason>} {<-print>} {<re>} ] redirects: [ (redir.Redir op: <Id.Redir_Great '>'> fd: -1 arg_word: {($ Id.VSub_DollarName '$file') <.new>} ) ] ) ] negated: F ) (C {<mv>} {<-f>} {($ Id.VSub_DollarName '$file') <.new>} {($ Id.VSub_DollarName '$file')}) (C {<Id.KW_Set set>} {<Id.Lit_Other '+'> <x>}) ] ) ) ] negated: F ) (C {<Id.KW_Set set>} {<-x>}) (command.Pipeline children: [ (C {<find>} {($ Id.VSub_DollarName '$DIR')} {<-type>} {<f>} {<-name>} {(DQ <'*.rei'>)}) (command.WhileUntil keyword: <Id.KW_While while> cond: [(command.Sentence child:(C {<read>} {<file>}) terminator:<Id.Op_Semi _>)] body: (command.DoGroup children: [ (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$OPAM_BIN') </refmt-> ($ Id.VSub_DollarName '$VERSION')} {<-is-interface-pp>} {<true>} {<-print>} {<binary_reason>} {($ Id.VSub_DollarName '$file')} ) (command.Simple words: [ {($ Id.VSub_DollarName '$OPAM_BIN') </refmt>} {<-is-interface-pp>} {<true>} {<-print-width>} {($ Id.VSub_DollarName '$PRINTWIDTH')} {<-use-stdin>} {<true>} {<-parse>} {<binary_reason>} {<-print>} {<re>} ] redirects: [ (redir.Redir op: <Id.Redir_Great '>'> fd: -1 arg_word: {($ Id.VSub_DollarName '$file') <.new>} ) ] ) ] negated: F ) (C {<mv>} {<-f>} {($ Id.VSub_DollarName '$file') <.new>} {($ Id.VSub_DollarName '$file')}) ] ) ) ] negated: F ) (C {<Id.KW_Set set>} {<Id.Lit_Other '+'> <x>}) (C {<echo>} {(DQ <'Done. Original files are backed up at '> ($ Id.VSub_DollarName '$BACKUP_DIR'))}) ] )