Meanwhile I found that it is possible to do this! This is going too far!
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
% Clean workspace
!cp get_me.m safe
!rm *.*
!mv safe get_me.m
!rm @*
% Clean user's function from some known jailbreaking mechanisms
fid = fopen('get_me.m');
st = regexprep(char(fread(fid)'), '!', 'error(''No shell commands!''); %');
st = regexprep(st, 'feval', 'error(''No fancy functions!''); %');
st = regexprep(st, 'str2func', 'error(''No fancy functions!''); %');
st = regexprep(st, 'regex', 'error(''No fancy functions!''); %');
st = regexprep(st, 'system', 'error(''No shell commands!''); %');
st = regexprep(st, 'dos', 'error(''No shell commands!''); %');
st = regexprep(st, 'unix', 'error(''No shell commands!''); %');
st = regexprep(st, 'perl', 'error(''No external languages commands!''); %');
st = regexprep(st, 'java', 'error(''No external languages commands!''); %');
fclose(fid)
fid = fopen('get_me.m' , 'w');
fwrite(fid,st);
fclose(fid)
% Release the Kraken!
get_me()
% Try to cleanup the mess
!cp get_me.m safe
!rm *.*
!mv safe get_me.m
!rm @*
path(pathdef) % undo any change on search path
assert(isequal(ans,now))
rm: cannot remove `@*': No such file or directory
ans =
0
ans =
0
ans =
38
ans =
0
ans =
0
ans =
0
ans =
42
/bin/bash: cp: command not found
[Warning: Function /users/msssystem18/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In verifyCode>evaluateCode at 227
In verifyCode at 40
In fevalJSON at 14]
./rm: line 1: !#/bin/bash: No such file or directory
[Warning: Function /users/msssystem18/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In verifyCode>evaluateCode at 227
In verifyCode at 40
In fevalJSON at 14]
/bin/bash: mv: command not found
[Warning: Function /users/msssystem18/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In verifyCode>evaluateCode at 227
In verifyCode at 40
In fevalJSON at 14]
./rm: line 1: !#/bin/bash: No such file or directory
[Warning: Function /users/msssystem18/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In verifyCode>evaluateCode at 227
In verifyCode at 40
In fevalJSON at 14]
[Warning: Function /users/msssystem18/assert.m has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.]
[> In userpath at 58
In pathdef at 670
In verifyCode>evaluateCode at 227
In verifyCode at 40
In fevalJSON at 14]
|
900 Solvers
Count from 0 to N^M in base N.
220 Solvers
235 Solvers
Remove white space from the string
168 Solvers
277 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!