< prev index next >

samples/exec.js

Print this page
rev 1392 : 8087136: regression: apply on $EXEC fails with ClassCastException
Reviewed-by: hannesw, lagergren


  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 // The $EXEC builtin function can be used to run external commands:
  35 $EXEC("ls")
  36 $EXEC("ls -la")
  37 
  38 // It can also be given a string to use as stdin:
  39 $EXEC("cat", "Hello, world!")
  40 
  41 // Additional arguments can be passed after the stdin argument, as an array of
  42 // strings, or a sequence of varargs:
  43 $EXEC("ls", "" /* no stdin */, "-l", "-a")
  44 $EXEC("ls", "" /* no stdin */, ["-l", "-a"])
  45 
  46 // Output of running external commands is returned from $EXEC:
  47 print($EXEC("ls"))
  48 




  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 // The $EXEC builtin function can be used to run external commands:
  35 $EXEC("ls")
  36 $EXEC("ls -la")
  37 
  38 // It can also be given a string to use as stdin:
  39 $EXEC("cat", "Hello, world!")
  40 
  41 // Additional arguments can be passed after the stdin argument, as an array of
  42 // strings, or a sequence of varargs:
  43 $EXEC("ls", "" /* no stdin */, "-l", "-a")
  44 $EXEC("ls", "" /* no stdin */, ["-l", "-a"])
  45 
  46 // Output of running external commands is returned from $EXEC:
  47 print($EXEC("ls"))
  48 
  49 // apply on $EXEC
  50 print($EXEC.apply(this, ["ls"]));
< prev index next >